Why are my Fluent NHibernate SubClass Mappings generating redundant columns?

Posted by Brook on Stack Overflow See other posts from Stack Overflow or by Brook
Published on 2010-12-25T22:18:30Z Indexed on 2010/12/26 5:54 UTC
Read the original article Hit count: 309

Filed under:
|
|
|

I'm using Fluent NHibernate 1.x build 694, built against NH 3.0

I have the following entities

public abstract class Card
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
    public virtual string Description { get; set; }

    public virtual Product Product { get; set; }
    public virtual Sprint Sprint { get; set; }
}
public class Story:Card
{
    public virtual double Points { get; set; }
    public virtual int Priority { get; set; }
    public virtual IList<Task> Tasks { get; set; }
}

And the following mappings

public class CardMap:ClassMap<Card>
{
    public CardMap()
    {
        Id(c => c.Id)
            .Index("Card_Id");

        Map(c => c.Name)
            .Length(50)
            .Not.Nullable();
        Map(c => c.Description)
            .Length(1024)
            .Not.Nullable();

        References(c=>c.Product)
            .Not.Nullable();

        References(c=>c.Sprint)
            .Nullable();

    }
}
public class StoryMap : SubclassMap<Story>
{
    public StoryMap()
    {
        Map(s => s.Points);
        Map(s => s.Priority);

        HasMany(s => s.Tasks);
    }
}

When I generate my Schema, the tables are created as follows

Card
---------
Id
Name
Description
Product_id
Sprint_id

Story
------------
Card_id
Points
Priority
Product_id
Sprint_id

What I would have expected would have been to see the columns Product_id and Sprint_id ONLY in the Card table, not the Story table.

What am I doing wrong or misunderstanding?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET