无法使用数据注解 [英] Unable to use data annotations

查看:181
本文介绍了无法使用数据注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在这里,我们试图让EF7一个手柄在比赛之前,我遇到了什么,我只能称之为疯狂。

So here we are trying to get a handle on EF7 ahead of the game and I'm running into what I can only call madness.

在EF6我用注释颇有几分,我想,超过到EF7它根据UnicornStore项目这是完全有效的进行,但我遇到的一个问题,其中的Visual Studio 2015年抱怨我没有系统的引用。 ComponentModel.DataAnnotations装配。很公平,我我引用添加到组装,现在我得到了来自DNX核心5.0以下内容:

In EF6 I use annotations quite a bit and I am trying to carry that over into EF7 which according to the UnicornStore project this is totally valid, however I'm running into a problem wherein visual studio 2015 complains that I don't have a reference to the System.ComponentModel.DataAnnotations assembly. Fair enough, I add my reference to the assembly and now I get the following from DNX Core 5.0:

Error   CS0234  The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) Lib.DNX Core 5.0

有关我的生活,我不能算出这个以什么怎么回事,因为当我看着UnicornStore作为我的参考有一个在project.json到组装的参考,然而,有一个在project.lock.json参考,据我了解,你不应该编辑该文件。

For the life of me I can't figure this out as to whats going on here, as when I look at the UnicornStore as my reference there's no reference to that assembly in the project.json, however there is a reference in the project.lock.json and as I understand it you're not supposed to edit that file.

最大的问题是什么我做错了?为什么DNX 4.5.x不抱怨的参考,但DNX核心5.0是什么?

The big question what am I doing wrong? Why would DNX 4.5.x not complain about the reference and yet DNX Core 5.0 is?

推荐答案

在.NET 4.6(也称为vNext)web项目对 Microsoft.AspNet的依赖。 MVC 。这在拉依赖一棵大树,数据注解是包下 Microsoft.DataAnnotations

The .Net 4.6(also called vNext) web project has a dependency on Microsoft.AspNet.Mvc. This pulls in a big tree of dependencies, the data annotations are under the package Microsoft.DataAnnotations

有关使用数据注释在项目中使用 Microsoft.DataAnnotations System.ComponantModel.DataAnnotations

for using Data annotation in your project use Microsoft.DataAnnotations in place of System.ComponantModel.DataAnnotations.

这篇关于无法使用数据注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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