I have a value
DateTime dt = DateTime.Parse("2015-10-12 14:24:40.582");
with it I do:
SomeEntity someEntity = new SomeEntity()
{
ID = 1,
ChangedOn = dt
};
context.SomeEntities.Add(someEntity);
What I found out: in database table the value stored is "2015-10-12 14:24:40.5830000"
I found it out manually with
SELECT CONVERT(datetime2, ChangedOn) FROM SomeEnititiesTable WHERE ID=1;
I load someEntity from database and do
bool ok = someEntity.ChangedOn.Equals(dt);
The problem is that ok == false
when I expect ok == true
. :|
How to make code first in entity framework generate column of type datetime2 instead of datetime in migrations?