Entity Framework 4.3 Code First Cannot Create Datetime2?

别说谁变了你拦得住时间么 提交于 2019-12-12 09:37:49

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/9466677/entity-framework-4-3-code-first-cannot-create-datetime2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!