我遇到了一個問題,在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