本文介绍了实体框架4.3代码首先不能创建Datetime2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库模型配置为使用datetime2格式而不是datetime。当生成数据库时,所有日期列都是datetime而不是datetime2。这是我的列配置代​​码;

 属性(a => a.LastOpened)
.HasColumnOrder(++ index)
.HasColumnType(datetime2)
.HasPrecision(0)
.IsRequired();

我可以发誓这在早期版本的EF中有效,如4.1,但我不明白为什么它现在不工作我正在连接到SQL Server 2008 R2 ...



任何帮助将不胜感激!



谢谢!

解决方案

从:

更新



现在可以使用EF4.3.1补丁。


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:

Update

The EF4.3.1 patch is now available. EF4.3.1 and EF5 Beta 1 Available on NuGet

这篇关于实体框架4.3代码首先不能创建Datetime2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 16:49