I have this POCO class :
public class MyClass
{
public int MyKey { get; set; }
public string Name { get; set; }
public bool DiscriminatorField { get; set; }
public string AnotherInfo { get; set; }
}
My database model is as such :
- Main
- ID int
- Name varchar
- DiscriminatorField bit
- Specific1
- ID int
- AnotherField varchar
- Specific2
- ID int
- AnotherField varchar
The question: Using fluent API (and most likely EntityTypeConfiguration
), how can I create this conditional mapping where AnotherField
of my entity gets filled by Specific1
if the discriminator is true
, and by Specific2
if the discriminator is false
?
Note: I do not want to create two different POCOs. I'm looking for something like this, but conditional.
Edit: Added the discriminator field to the POCO entity.