I keep getting this error :
Cannot insert the value NULL into column ‘Id’, table
‘database.dbo.Employees’; column does not allow nulls. INSERT
fails.\r\nThe statement has been terminated.
But the object has this property set with Guid.NewGuid()
I use Entity Framework 4.1 and .net framework 4.0.
The column is primary key and not null. I’m not using Code First approach.
Edit : it seems that the Run Custom tool won’t update the file if I edit manually the file edmx.
This can happen if you have marked the key property as an autogenerated identity in your model with Fluent API or data annotations…
… (which has the effect that EF won’t send the
Idvalue to the database because it expects that the key is generated there) but in your database table you didn’t specify that the default value for theIdcolumn isnewid()so that the database doesn’t generate a new key.I you want to send the
Guidvalue manually from the client to the database remove theDatabaseGeneratedOption.Identityspecification from your model.