Closed lttrung11 closed 5 years ago
OK, the error says that the database is setting a default DateTime for the column CreateDate when you create a row, and EF Core doesn't know about that. The problem is I have DateTime columns like yours and I don't get that error.
Is the database created by EF Core, or is it an existing database? It feels like there is a default value on that column but that only makes sense if its build with a default value, e.g. [CreateDate] [datetime2](7) NOT NULL DEFAULT GETDATE()
. If that is so then you need to add a default value in EF Core and then CompareEfWithDb will be happy (or add this as an Ignore message).
Thank you very much. I will go with GETDATE() default value.
I got this error in a call to CompareEfWithDb: DIFFERENT: CommandGroup->Property 'CreateDate', default value sql. Expected =, found = '0001-01-01T00:00:00.0000000'\nDIFFERENT: CommandGroup->Property 'CreateDate', value generated. Expected = Never, found = OnAdd
I may not configure it correctly, but this CreateDate field is a standard DateTime field, with default configuration of EF Core 2.2: public DateTime CreateDate { get; set; }
In SQL Server: [CreateDate] datetime2 NOT NULL