私はユーザーエンティティクラスを使用しました:
public class Users
{
public int UserId { get; set; }
public string NickName { get; set; }
public string FirstName { get; set; }
public string Password { get; set; }
public DateTime BirthDate { get; set; }
public int Age { get; set; }
public string CountryName { get; set; }
public string Email { get; set; }
public int Gender { get; set; }
public int DayInvitation { get; set; }
public string CityName { get; set; }
public string EyesColors { get; set; }
public string Avatar { get; set; }
public int Popularity { get; set; }
}
次のエラーが発生しました:
System.Data.Entity.Edm.EdmEntityType: : EntityType 'Users' にはキーが定義されていません。
そこで、[Key] キーワードを追加しました。
public class Users
{
[Key]
public int UserId { get; set; }
public string NickName { get; set; }
public string FirstName { get; set; }
// ...
}
私の質問は、この [Key] 注釈を使用せずに、ProductId を指定するだけで別の ASP .NET プロジェクト (私の最初のもの、これが 2 番目のもの) を実行したことは確かです。誰かが理由を説明できますか? 理解できません..