I am just starting to learn a bit about the entity framework and don't have much experience with ORM's.
In my little app I have one table, this sql server table has several columns including a PrimaryKey (int) a Name (string) and a Flag (tinyint).
When I imported this table into it automatically assigned the Flags' datatype as a byte. This is fine, but the Flag should really be a boolean, so I
- Clicked on the Mapping Details
- Selected my Flag property
- Changed the Type from Byte to Boolean
- Rebuilt the application
I then got this error:
Error 2019: Member Mapping specified
is not valid. The type
'Edm.Boolean[Nullable=True,DefaultValue=]'
of member 'MyFlag' in type
'MyModel.MyItem' is not compatible
with
'SqlServer.tinyint[Nullable=True,DefaultValue=]'
of member 'MyFlag' in type
'MyModel.Store.MyItem'.
Is there a way to have
MyItem item = new MyItem();
item.Flag = true;
and have Flag save to 1 in the database?
Best Answer
You could change the datatype of
MyFlag
tobit
in the database.