I have a simple model I\'m attempting to persist using fluent-nhibernate:
public class Person
{
public int Id { get; set; }
public string Name { get; set
With a little tweak to your original code this can be achieved, for clarity I will post the entire code,
public class Person
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IList Addresses { get; set; }
}
public class Address
{
public virtual int Id { get; set; }
public virtual int PersonId { get; set; }
public virtual string Street { get; set; }
}
public class PersonOverrides : IAutoMappingOverride
{
public void Override(AutoMapping mapping)
{
mapping.Id(x => x.Id);
mapping.HasMany(x => x.Addresses).KeyColumn("PersonId").Cascade.All();
}
}
Here is the changed code,
public class AddressOverrides : IAutoMappingOverride
{
public void Override(AutoMapping mapping)
{
mapping.Id(x => x.Id);
mapping.Map(x => x.PersonId).Column("PersonId");
}
}