How do I tell Entity Framework that a column in a view is nullable?
Posted
by Ryan ONeill
on Stack Overflow
See other posts from Stack Overflow
or by Ryan ONeill
Published on 2010-05-15T14:44:41Z
Indexed on
2010/05/15
14:54 UTC
Read the original article
Hit count: 173
entity-framework
|.NET
I have a view which has an Int column which is nullable (let's call it StackOverflowCount). When generating an EF model from the database, the EF designer does not recognise it as nullable and creates the column as an Int.
The issue I have is that on the EF designer I have set the column to Nullable and the following error then kills the compilation;
Error 3031: Problem in mapping fragments starting at line 2327:
Non-nullable column MyView.StackOverflowCount in table MyView
is mapped to a nullable entity property.
I can get round this by opening the .edmx file in XML mode and manually editing the SQL column definition, but there is no way to do this using the designer and it gets overwritten the next time I refresh from the model from the DB.
Is this 'by design' or an example of something that slipped through into EF 4.0? I'm using .Net 4.0 with EF 4.0 under VS 2010.
© Stack Overflow or respective owner