0

Here I have the mapping for the parent and child-class:

public class Parent
{
    public virtual int ParentId { get; set; }
    public virtual string ParentName{ get; set; }
}

public class Child : Parent
{
    public virtual string ChildName{ get; set; }
}

And the mappings:

public class ParentMap: ClassMap<Parent>
{
    public ParentMap()
    {
        Id(x => x.ParentId ).GeneratedBy.Identity();
        Map(x => x.ParentName);
    }
}

public class ChildMap : SubclassMap<Child>
{
    public ChildMap ()
    {
        Map(x => x.ChildName);
    }
}

Now I have the problem that the Id-Column has another name than the convention expects. The convention would like to have Parent_id for the join, but I would like to define a custom name. How can I define the custom name?

Thx for any tipps

P.s.: Since this case is an exception, I don't want to create an own convention.

sl3dg3
  • 5,026
  • 12
  • 50
  • 74

1 Answers1

0

Ah, figured it out:

public class ChildMap : SubclassMap<Child>
{
    public ChildMap ()
    {
        KeyColumn("ParentId")
        Map(x => x.ChildName);
    }
}
sl3dg3
  • 5,026
  • 12
  • 50
  • 74