I have this code:
class Country
{
public int CountryId { get; set; }
public string CountryName { get; set; }
}
class Emp开发者_如何学Pythonloyee
{
public int EmployeeId { get; set; }
public string EmployeeName { get; set; }
public int ResidingInCountryId { get; set; }
public virtual Country ResidenceCountry { get; set; }
}
What should I put on OnModelCreating? So I can navigate the Country's CountryName from Employee
I'm quoting directly from this blog posting by Ian Nelson, but I think this is what you need:
Here's how you’d rename a foreign key on a unidirectional one-to-many relationship in Fluent NHibernate:
References(x => x.AudioFormat).Column("AudioFormat");
Whilst in Entity Framework code-first, the equivalent is:
HasOptional(x => x.AudioFormat)
.WithMany()
.IsIndependent()
.Map(m => m.MapKey(a => a.Id, "AudioFormat"));
精彩评论