I have this table in my database
Table Project
ProjectId (int), ProjectName (varchar(50)), ProjectCreationDate(datetime2(7))
ProjectId is the identity
ProjectName is non-null allowable with no default value
ProjectCreationDate has a default binding (sysdatetime())
I create a ADO.NET EDM and attempt to insert into the table
using (ProjectEntities context = new ProjectEntities()){
Project p = Project{
ProjectName = "ADO"
};
context.Projects.AddObject(p);
context.SaveChanges();
}
The problem is the ProjectCreationDate column is populated with 0001-01-01 00:00:00.0000000 while I was expecting the current time that will be populated by the database itself.
I have other tables in my database with default value binding and the value will be changed later one. So setting StoreGeneratedPattern = "computed" isn't the solution I am look for.
Any ideas?