我在 Visual Studio 2012 中遇到涉及 System.ComponentModel.DataAnnotations.Schema 命名空间的问题。它告诉我ForeignKeyAttribute无法解析,过去的解决方案是添加下面注释掉的using语句。 VS2012 无法像 VS2010 那样解析架构命名空间。最近的 .Net 版本中是否有任何更改会导致此问题?如果是这样,我该如何解决它们?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
// using System.ComponentModel.DataAnnotations.Schema;
namespace Data
{
public class AffiliateUser
{
[Key, ForeignKey("User")]
public int UserId { get; set; }
[StringLength(50)]
public string AffiliateUserKey { get; set; }
public Guid ApiKey { get; set; }
public string PasswordHash { get; set; }
public bool IsDeleted { get; set; }
}
}
您确定您的目标是.NET 4.5 Framework吗?外键属性 http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.schema.foreignkeyattribute.aspx仅在 .NET 4.5 中可用
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)