I have classes something like below. I would like to reuse classes and persist them in different tables by using entity framework code first.
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsAvailable { get; set; }
public List<Part> Parts { get; set; }
public List<Promotion> Promotions { get; set; }
}
public class Field
{
public int Id { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
public class Part
{
public int Id { get; set; }
public string Name { get; set; }
public List<Field> Details { get; set; }
}
public class Promotion
{
public int Id { get; set; }
public string Name { get; set; }
public List<Field> Details { get; set; }
}
I want to map my entities such a way that I would get database tables generated like below.
Products: Id, Name, IsAvailable
ProductParts: Id, Name, ProductId
ProductPartDetails: Id, Name, Value, ProductPartId
ProductPromotions: Id, Name, ProductId
ProductPromotionDetails: Id, Name, Value, ProductPromotionId
What I am actually interested in here is I want the Field class reused and gets stored in different tables ProductPartDetails and ProductPromotionDetails as I described above. Is it possible or my approach needs to be changed?
Fieldto that table as a property. Make fieldComplexTypeso it'd be 'reused` (just translates to fields, not table on its own). Something like that for both. If you can try something yourself based on this - I don't have time right now - and I'll take a look what you did and feel in the gaps. - NSGaga-mostly-inactiveCategoryItemValue> here < - NSGaga-mostly-inactive