开发者

There is no Key attribute in EF CTP 5

开发者 https://www.devze.com 2023-02-02 13:37 出处:网络
According to the blog post here Data Annotations in the Entity Framework there should be an attribute for a column called \"Key\" which allows you to mark the primary key of an entity.However I cannot

According to the blog post here Data Annotations in the Entity Framework there should be an attribute for a column called "Key" which allows you to mark the primary key of an entity. However I cannot locate this in .Net 3.5 or .Net 4.0.

What have I missed? I've in开发者_StackOverflowcluded the reference to EntityFramework.dll and I've checked all the attributes under System.ComponentModel.DataAnnotations but I cannot locate it.

There is no Key attribute in EF CTP 5

I have set my project to .Net 4.0 full (not client profile).

Any ideas?


The KeyAttribute is .NET 4 only and it is located in the System.ComponentModel.DataAnnotations assembly so make sure you have referenced it.


Probably your project is not targeting Framework 4.0, so, when you add the System.ComponentModel.DataAnnotations reference, it will not correspond to the 4.0 version, that is the version that has the "Key" definition.

Try deleting your current DataAnnotation reference, then change the project's target framework (right click the project -> Properties -> Application -> Target Framework) to .Net 4.0, and then add the reference to DataAnnotations again. Worked for me ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消