The child/dependent side could not be determined for the one-to-one relationship

后端 未结 1 1144
一向
一向 2021-02-13 17:15

I am trying to update my database with \"update-database\" command in package manager console, But I have this kind of error:

The child/dependent side could not          


        
相关标签:
1条回答
  • 2021-02-13 18:06

    You have to put the below code in your DBContext class, not in SnapShot class. Don’t modify the Snapshot class, it’s auto generated class.

    modelBuilder.Entity<Country>()
                .HasOne(a => a.CapitalCity)
                .WithOne(a => a.Country)
                .HasForeignKey<CapitalCity>(c => c.CountryID);
    
    0 讨论(0)
提交回复
热议问题