Reputation: 132548
I thought I saw something somewhere about being able to generate an object in EF with all the non-null values filled in with generic values.
I tried using context.CreateObject<MyEntity>()
, however I am still getting errors about trying to save NULL data to a non-null column.
Was I mistaken in thinking this? Or do I just have the wrong syntax?
Upvotes: 3
Views: 1247
Reputation: 57783
In the model designer, you can enter a default value on the property sheet for each field.
Upvotes: 3
Reputation: 13399
You can not save null data to a non-nullable column. If CreateObject
method gives you that you'll need to change that before trying to save data. Also, watch out for DateTime
objects, SQL server has different min value of that than the .NET.
Upvotes: 2