I have a simple class:
public class Member
{
public int AccountId { get; set; }
public string Name { get; set; }
public string Role { get; set; }
public DateTime MemberSince { 开发者_开发百科get; set; }
}
I need to make the AccountId a key but if I use the "Key" attribute it turns it into an identity which won't work for me (this data comes from another source so the value cannot be changed).
Is there another way to do this?
There is almost the exact same question here except the answer uses the fluent interface which I cannot do.
Sure, you can use:
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public int AccoungId { get; set; }
精彩评论