实体框架4.3代码首先不能创建Datetime2? [英] Entity Framework 4.3 Code First Cannot Create Datetime2?
问题描述
属性(a => a.LastOpened)
.HasColumnOrder(++ index)
.HasColumnType(datetime2)
.HasPrecision(0)
.IsRequired();
我可以发誓这在早期版本的EF中有效,如4.1,但我不明白为什么它现在不工作我正在连接到SQL Server 2008 R2 ...
任何帮助将不胜感激!
谢谢!
从 ADO.NET团队博客:
已知问题
[...]
- 并非所有硬编码列数据类型都在生成的
数据库中得到保证。如果您使用列数据注释或HasColumnType
Fluent API方法来硬编码列数据类型(即xml,money,
等),则在创建数据库时不会使用此数据类型。我们将在4.3.1补丁版本中为
包含此问题的修复。
更新
现在可以使用EF4.3.1补丁。 EF4.3.1和EF5 Beta 1在NuGet上可用
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
这篇关于实体框架4.3代码首先不能创建Datetime2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!