Below example of one-to-one relationship throws an exception
public class User { public int Id { get; set; } public Address Address { get; set; } }
You need to use fluent API to map the relationship as shared primary key.
public class MyContext : DbContext { protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity() .HasRequired(a => a.User) .WithOptional(u => u.Address); } }