If I have a User
class that has these properties:
public Guid UserPreferenceId { get; set; }
public virtual DefaultUserPreference UserP
Entity Framework creates relationships with Cascade Delete on by default. Creating two relationships from one entity to another type tries to create two cascade-delete relationships, which the database will throw the error you saw for.
Use the Code-First Fluent Configuration to remove the Cascade Delete on one or both of the relationships:
modelBuilder.Entity<User>()
.HasOptional(u => u.UserPreference)
.WithMany()
.WillCascadeOnDelete(false);
modelBuilder.Entity<User>()
.HasOptional(u => u.SecondaryUserPreference)
.WithMany()
.WillCascadeOnDelete(false);