I am using Entity Framework 6 and SQL Server 2014 to store data. I have a table with 4 column, and the CreatedOn
column has a default with current datetime in SQL Server.
When I add record in table from SQL Server by writing query it works correctly, but when I try to add record from Entity Framework, it fills in null
into the CreatedOn
column.
My table schema is:
My ASP.NET code-behind looks like this:
I also try by changing column datatype to datetime2
, but no luck.
What changes do I need to make to make it work with EF? I don't want to pass date from asp.net.
When I see output of select getutcdate()
in SQL Server, it shows the correct value.