Visual Studio 2012可移植类库和System.ComponentModel.DataAnnotations.Schema引用

时间:2013-06-25 11:29:42

标签: c# visual-studio entity-framework silverlight

我使用visual studio 2012并创建portable class library来定义我的数据库域。 当我使用class library时,可以添加System.ComponentModel.DataAnnotationsSystem.ComponentModel.DataAnnotations.Schema引用,并可以使用ForeignkeyTableNotMapped属性来定义我的域类。但是当创建portable class library时,我无法使用此属性,也无法添加上述引用。 我想创建Silverlight应用程序,但不能引用类库。

提前感谢。

2 个答案:

答案 0 :(得分:1)

只是因为ForeignKeyAttribute仅在.net 4.5中支持,而不支持可移植类库。检查兼容性here(图标)。

因为Silverlight“正在”死亡,所以永远不会支持它。

在.net 4.5和System.ComponentModel.DataAnnotations命名空间中添加了许多内容,PCL中也有不受支持的属性。

答案 1 :(得分:0)

您可以使用EntityFramework流畅的API方法来注册PCL中不支持的任何POCO类/属性属性。另一种选择是在命名POCO属性时使用约定。更多信息可以在http://msdn.microsoft.com/en-us/data/hh134698.aspx

找到
相关问题