如何以及是否实体框架6支持.NET 4.0? [英] How well does Entity Framework 6 support .NET 4.0?

查看:112
本文介绍了如何以及是否实体框架6支持.NET 4.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题上遵循从喜欢的确实实体框架6支持.NET 4.0?
我的问题是具体,我如何利用 NotMapped 数据标注与EF6和.NET 4.0版的?

This question follows on from previous questions like Does Entity Framework 6 support .NET 4.0?
My question is specifically, how do I make use of the NotMapped data annotation with EF6 and .NET v4.0?

大多数文章中,我能找到假设开发商也迁移到.NET 4.5版或更高版本,在数据注解的命名空间已被转移到 System.ComponentModel.DataAnnotations.Schema ,住在 System.ComponentModel.DataAnnotations DLL。

Most articles I can find assume the developer has also migrated to .NET v4.5 or later, where the data annotations namespace has been moved to System.ComponentModel.DataAnnotations.Schema and lives in the System.ComponentModel.DataAnnotations dll.

推荐答案

在.NET 4.0版本的实体框架6中包含的定义 NotMappedAttribute 直接在 EntityFramework.dll 。它存在于同一个命名空间,即 System.ComponentModel.DataAnnotations.Schema

The .NET 4.0 version of Entity Framework 6 contains a definition of NotMappedAttribute directly in EntityFramework.dll. It exists in the same namespace, namely System.ComponentModel.DataAnnotations.Schema.

您将需要确保你的.NET 4.0版本的EF,虽然。如果你的项目是previously针对.NET 4.5,和您添加EF在那个时候,你已经得到了.NET 4.5版EF的。更改该项目​​以.NET 4.0是不够的,解决这个问题。你需要在你的项目中删除EF和重新添加。

You will need to make sure you have the .NET 4.0 version of EF, though. If your project was previously targeting .NET 4.5, and you added EF at that time, you've got the .NET 4.5 version of EF. Changing the project to .NET 4.0 is not enough to fix this. You'll need to remove EF from your project and re-add it.

这篇关于如何以及是否实体框架6支持.NET 4.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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