我在 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; }
}
}