I have one entity CustomProperty
in domain model which is used from several other entities.
Product
{
int Id;
Collection<CustomProperty> CustomProperties;
}
and
Order
{
int Id;
Collection<CustomProperty> CustomProperties;
}
But in DB, I do not want just one table CustomProperty
which contains nullable foreign key to Product
table and another nullable foreign key to Order
. Instead, I need two separate tables ProductCustomProperty
and OrderCustomProperty
.
I need to do that with automapping and conventions. Does anyone have any ideas?
Btw, I have had an idea which does not work for me. Maybe anyone have the clue why:
public class CustomPropertyConvention : IHasManyConvention, IHasManyConventionAcceptance
{
public void Apply(IOneToManyCollectionInstance instance)
{
instance.Table("ProductCustomProperty");
}
public void Accept(IAcceptanceCriteria<IOneToManyCollectionInspector> criteria)
{
criteria.Expect(i => i.Relationship.Class.Name == "CustomProperty" && i.Relationship.EntityType == typeof(Product));
}
}
This example must have worked perfectly, but IOneToManyCollectionInstance.Table() does not set anything.