Entity Framework 6如何支持.NET 4.0?

编程入门 行业动态 更新时间:2024-10-23 12:37:26
本文介绍了Entity Framework 6如何支持.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?

本文发布于:2023-11-12 11:53:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581433.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Framework   Entity   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!