Problem with non-nullable columns with default values in EF data model
I have a DB table with two int columns that are not nullable, but are defined with default v开发者_如何学运维alues of zero. Both columns are not used in the model I am busy with, so I am trying to keep then out of the conceptual model. If I delete them there, I get uphill because the store model columns are not mapped. If I delete them from the store model, or add defaults in the store model, my changes get undone whenever I update the model. It seems a pretty poor showing to me that the designer doesn't honour SQL server default values for the columns, and neither am I really allowed to intervene and do this job for it. How can I ignore these columns without changing my db schema?
Yes, the designer is somethimes very annoying, when you have to modify the xml file directly for (sometimes not very) advanced scenarios.
A possible workaround for your problem might be to use a view instead of the table. just create a view without the two columns and EF won't see the columns anymore.
精彩评论