Home > Software design >  SQL GETDATE() Inserting 01/01/001 12:00:00 AM to database
SQL GETDATE() Inserting 01/01/001 12:00:00 AM to database

Time:05-04

In my service-based SQL database one of my table has a column 'feedbackdate' with default value GETDATE(). I am using entity framework to insert data to the table and not mentioning the said column in the insert statement but GETDATE() function is inserting 01/01/001 12:00:00 AM . I also tried current_timestamp and sysdatetime() and sysdatetime().NOW() as Default-Value but result is same.

I also changed the DataType of column from date to datetime2(0) but no luck.

Column definition in table

[feedBackDate]      DATETIME2 (0)  DEFAULT (sysdatetime()) NOT NULL,

Note: I am using Database-First Model and in EntityDataModel the mapped column's Default Value is NONE

CodePudding user response:

I've got it. The problem is with the Mapped Column in .edmx file. I've changed the StorGenereatePattern from None to Computed of the mapped column and bingo.

  • Related