实体框架5 .NET 4.0 - DatabaseGeneratedOption.Identity未定义 [英] Entity Framework 5 on .NET 4.0 - DatabaseGeneratedOption.Identity is undefined

查看:397
本文介绍了实体框架5 .NET 4.0 - DatabaseGeneratedOption.Identity未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用EF5在.NET 4中,我已经在与不在的4.0版本的库存在HasDatabaseGenerationOption.Identity映射我班碰到一个参考的问题。

I need to use EF5 on .NET 4 and I've run into a reference issue when mapping my class with HasDatabaseGenerationOption.Identity which doesn't exist in the 4.0 version of the library.

下面是失败的:

this.Property(t => t.DeploymentLogId)
              .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

有谁知道周围的工作吗?

Does anyone know of a work around?

推荐答案

使用的NuGet来的EntityFramework添加到面向.NET 4.5的项目,将新增的EntityFramework 5.0。

Using NuGet to add EntityFramework to a project that targets .NET 4.5, will add EntityFramework 5.0.

如果您以后将项目更改为面向.NET 4.0,5.0的EntityFramework仍然引用。

If you later change the project to target .NET 4.0, EntityFramework 5.0 is still referenced.

要解决这个问题,使用的NuGet卸载的EntityFramework并将其添加回,也是在的NuGet。这将增加的EntityFramework 4.4是最后支持版本的.NET 4.0。

To fix it, use NuGet to uninstall EntityFramework and add it back, also in NuGet. This will add EntityFramework 4.4 which is the last supported version for .NET 4.0.

如果仍然无法正常工作,有可能是在的App.config 一些参考具体的EF版本。这些可以被删除。

If it still does not work there may be some references to the specific EF version in App.config. These can be removed.

这篇关于实体框架5 .NET 4.0 - DatabaseGeneratedOption.Identity未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆