Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy are my Fluent NHibernate SubClass Mappings generating redundant columns?
    primarykey
    data
    text
    <p>I have the following entities</p> <pre><code>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 class Product { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IList&lt;Story&gt; Stories { get; private set; } public Product() { Stories = new List&lt;Story&gt;(); } } </code></pre> <p>And the following mappings</p> <pre><code>public class CardMap:ClassMap&lt;Card&gt; { public CardMap() { Id(c =&gt; c.Id) .Index("Card_Id"); Map(c =&gt; c.Name) .Length(50) .Not.Nullable(); Map(c =&gt; c.Description) .Length(1024) .Not.Nullable(); References(c=&gt;c.Product) .Not.Nullable(); References(c=&gt;c.Sprint) .Nullable(); } } public class StoryMap : SubclassMap&lt;Story&gt; { public StoryMap() { Map(s =&gt; s.Points); Map(s =&gt; s.Priority); } } public class ProductMap:ClassMap&lt;Product&gt; { public ProductMap() { Id(p =&gt; p.Id) .Index("Product_Id"); Map(p =&gt; p.Name) .Length(50) .Not.Nullable(); HasMany(p =&gt; p.Stories) .Inverse(); } </code></pre> <p>When I generate my Schema, the tables are created as follows</p> <pre><code>Card --------- Id Name Description Product_id Sprint_id Story ------------ Card_id Points Priority Product_id Sprint_id </code></pre> <p>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.</p> <p>What am I doing wrong or misunderstanding?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload