How to manage GetDate() with Entity Framework
Posted
by wcpro
on Stack Overflow
See other posts from Stack Overflow
or by wcpro
Published on 2010-04-29T20:28:59Z
Indexed on
2010/04/29
20:37 UTC
Read the original article
Hit count: 1523
entity-framework
|sql-server-2008
I have a column like this in 1 of my database tables
DateCreated, datetime, default(GetDate()), not null
I am trying to use the Entity Framework to do an insert on this table like this...
PlaygroundEntities context = new PlaygroundEntities();
Person p = new Person
{
Status = PersonStatus.Alive,
BirthDate = new DateTime(1982,3,18),
Name = "Joe Smith"
};
context.AddToPeople(p);
context.SaveChanges();
When i run this code i get the following error
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated.
So i tried setting the StoreGeneratedPattern to computed... same thing, then identity... same thing. Any ideas?
© Stack Overflow or respective owner