I'm trying to implement a code-first scenario where Abstract Base classes are used ONLY for defining the table-models
the point is to define similar properties ONCE and then let the inheritance work its magic.
what i'm experiencing and have found out the hard way, is that i have to choose between TPT, TPH or TPC inheritance modelling where none of them give me what i want.
TPC seems to be the most relevant - but i CANNOT fathom why EF6 creates Tables for the Abstract baseclasses !??
I dont want to create collections of type: <abstract baseclass> like seen in this example: https://weblogs.asp.net/manavi/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-3-table-per-concrete-type-tpc-and-choosing-strategy-guidelines
i don't get why you would ever do that .. meaning - why you would add inherited classes into a dbcontext of type <abstract baseclass> .. ???
Is it possible to have EF, ONLY use the concrete instantiable classes and somewhat ignore the abstract classes ?
eg:
abstract class BaseModel
{
public int ID {get;set;}
}
class A : BaseModel
{
public string A {get;set;}
}
class B : BaseModel
{
public string B {get;set;}
}
// Should result in
Table A [ ID int, A varchar() ]
Table B [ ID int, B varchar() ]