Search code examples
entity-frameworkn-tier-architectureedmxupdatemodelfacet

Property facet Nullable = None is overridden in Model.edmx xml on Update Model from Database


Using Entity Framework 6, I need to maintain a property facet value when using the Model wizard to update.

My property is not nullable in the database, but I have my property facet set as Nullable = None, and my model facet set as Update Property Facets = False. I have to manually edit the Model.edmx file to remove the Nullable="false" attribute from the property. The solution builds successfully in this state. The problem is when I do an Update Model from Database, the Model.edmx file adds back the Nullable="false" attribute and when I build I receive the error that "Error 3031: Problem in mapping fragments starting at line 999:Non-nullable column COLUMN_NAME in table TABLE_NAME is mapped to a nullable entity property."

How do I prevent the Model.edmx from adding the Nullable="false" attribute when running the Model wizard?

This is related to issue Designer: No way to mark facets of entity properties not to be overriden by database facets but slightly different.

I think this is an EF issue, but please note that we are using the NTier Entity Framework (NTIER)

@ChristofSenn Do you have any suggestions?


Solution

  • Apparently this is a known issue with no fix in the near future, as referenced on CodePlex. Property facet Nullable = None is overridden in Model.edmx on Update Model from Database