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; }
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
HasForeignKey
WithMany
HasRequired(x => x.User).WithMany().HasForeignKey(x => x.Id); HasRequired(x => x.City).WithMany().HasForeignKey(x => x.CityId);