Property name in a type must be unique

后端 未结 3 1307
情话喂你
情话喂你 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条回答
  •  Happy的楠姐
    2021-02-13 10:51

    In addition to Slauma's answer

    HasForeignKey is not available for 1:1, if you still need it you can simply use WithMany without parameters

    HasRequired(x => x.User).WithMany().HasForeignKey(x => x.Id);
    HasRequired(x => x.City).WithMany().HasForeignKey(x => x.CityId);
    

提交回复
热议问题