I have a table with column type of datetime2 (it was datetime, but EF as I see works with datetime2).
I have set it as not null and with default value of SYSDATETIME(). In order to work normaly I have set the property which maps to this column in EF model as Computed. Now when I am not seting any value in that property I can see notmal record in table, but when I try to set the value from code it ignores it and in all cases set SYSDATETIME().
How it is possible to insert default value which is set in DB when no value is in the property in model and value of the property if it is not null and set?
EDIT : Here is sample code
.....
ActionsJournal actionsJournalEntry =
TestFactory.CreateActionEntry(.....);
if (/* some condition */)
{
actionsJournalEntry.CreatedDate = DateTime.Now.AddDay(30); // else it will be null
}
ent.ActionsJournals.AddObject(actionsJournalEntry);
ent.SaveChanges();
....
StoreGeneratedPatternandDefaultValue. IfStoreGeneratedPatternisComputed, then you're saying that the database always sets/resets this value.