我在Visual Studio 2012中遇到涉及System.ComponentModel.DataAnnotations.Schema命名空间的问题.它告诉我,ForeignKeyAttribute无法解析,过去的解决方案是添加下面注释掉的using语句.VS2012无法像VS2010那样解析Schema名称空间.最近的.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; }
}
}
Run Code Online (Sandbox Code Playgroud)