Since we keep adding more and more properties to entities we decided instead of using tables for each type to use a generic new property called IdContainer which contains a set of properties.
In fluent API Configuring One to Many is very easy, but I am having some trouble here.
Usually, when having navigation properties on both sides I would so something like:
builder.Entity<Entity>(e => e
.HasMany(m => m.Properties)
.WithRequired(m => m.Entity)
.HasForeignKey(f => f.IdContainer)
But this case is different because there is no navigation property as it can be linked to many different types of entities.
In reality there is also another table called Container which only contains an Identity column IdContainer. The only purpose of the table is for generating a new ID to associate entities with their containers.
So my question is how can map the properties to the specific entities so that I can access them in a fashion similar to:
Entity.Properties.FirstOrDefault().Name;
Also, with this code the website goes up, but when trying to add a property like this:
Entity.Properties.Add(new Property{
IdContainer = Entity.IdContainer.Value,
IdProperty = IdProperty
});
I get an null reference error after attaching to db and saving, but solved this by just inserting it directly instead of adding it like this.
