我遇到了一个问题,在Visual Studio 2012,涉及到System.ComponentModel.DataAnnotations.Schema命名空间。它告诉我ForeignKeyAttribute无法解析,过去的解决方案是添加下面注释的using语句。由于VS2010能够解决VS2012无法解析的架构名称空间问题。最近的.Net版本有什么变化会导致这个问题?如果是这样,我该如何解决他们?System.ComponentModel.DataAnnotations.Schema没有找到
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; }
}
}
就是这样,感谢您的帮助。 – ThirtyApes
是的,这也救了我。默认情况下,我的课程库是4.0 – Simon