Property name in a type must be unique

后端 未结 3 1293
情话喂你
情话喂你 2021-02-13 10:45

I am using Entity Framework 5 and I have the following entities:

public class User {
  public Int32 Id { get; set; }
  public String Username { get; set; }    
          


        
3条回答
  •  醉梦人生
    2021-02-13 10:47

    MapKey is only used if your foreign key column is not exposed as a property in your model. But in your case it is - as property Claim.Id. In that case you must use HasForeignKey instead of MapKey:

    HasRequired(x => x.User)
        .WithMany(y => y.Claims)
        .HasForeignKey(x => x.Id);
    

提交回复
热议问题