Entity Framework 6如何支持.NET 4.0? [英] How well does Entity Framework 6 support .NET 4.0?
问题描述
这个问题遵循以前的问题,例如 Entity Framework 6是否支持.NET 4.0?
我的问题具体来说,我如何使用 NotMapped
数据注释与EF6和.NET v4.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 v4.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版本的Entity Framework 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。如果您的项目以前是针对.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.
这篇关于Entity Framework 6如何支持.NET 4.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!