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

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);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)