I have my database model configured to use the datetime2 format instead of just datetime. When the database is generated all date columns are datetime and not datetime2. Here is my column configuration code;
Property(a => a.LastOpened)
.HasColumnOrder(++index)
.HasColumnType("datetime2")
.HasPrecision(0)
.IsRequired();
I can swear that this worked in the earlier version of EF such as 4.1 but I don't understand why it isn't working now. I am connecting to SQL Server 2008 R2...
Any help would be appreciated!
Thank You!
From the ADO.NET team blog:
Known Issues
[...]
- Not all hard coded column data types are honored in generated databases. If you use the Column data annotation or HasColumnType Fluent API method to hard code a column data type (i.e. xml, money, etc.), this data type is not used when creating the database. We will be including a fix for this issue in the 4.3.1 patch release.
Update
The EF4.3.1 patch is now available. EF4.3.1 and EF5 Beta 1 Available on NuGet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With