I am trying to map two concrete entity types and an abstract base type to the same database table.
The table contains a bit column that does not accept null. Column has a default value: ((0)).
Only one of the two concrete entity types (i.e. concrete type 1) needs to use the column's value (for the other (i.e. concrete type 2) it is always false).
I tried adding a property mapped to that column only to the entity type which requires it and a
When I call SaveChanges I get an UpdateException, with the following message on its inner-most-exception:
"The column cannot contain null values. [ Column name = MY_BIT_COLUMN,Table name = MY_TABLE ]"
I already edited the SSDL section of the EDMX and changed:
<Property Name="MY_BIT_COLUMN" Type="bit" Nullable="false" />
to:
<Property Name="MY_BIT_COLUMN" Type="bit" Nullable="false" DefaultValue="false" />
(Without this change mapping failed - will not run)
Is there any way to get around this without adding a property mapped to this column to the second concrete entity type or moving it to the base type?
Adding property as protected to concrete type 2 does work, but I would prefer a more elegant workaround.