I’ve been trying to map an existing Data Model I have to Entity Framework as an exercise. The model has a setup that requires me to essentially search an existing table of “Types” to find the table representing each Type
e.g.
TABLE STORE_TYPE
ID Type Table
1 Retail STORE_RETAIL
2 Grocery STORE_GROCERY
TABLE STORE_RETAIL
ID StoreName Location Manager
1 RetailStuffs 1 1st St Chad
TABLE STORE_GROCERY
ID StoreName Location Size
1 FoodStuffs 2 2nd St 15000
Basically the user can define N number of store types and then I query those types to find the table of stores associated to each type. So in the example I would query the STORE_TYPE table to get to the STORE_RETAIL table and STORE_GROCERY_TABLE. Each table consists of a number of known columns along with N number of other columns. I’ve already created entities to represent the known columns for a STORE type but I’m not sure how to map them.
Is there anyway for me to map these tables in EF without knowing about them before hand? I’ve been working with the Programming Entity Framework book and searching online and have found no good solutions.
There is no way. EF is for static databases which are well known at design time. Scenarios where tables can be defined at runtime or can have columns defined at runtime are not scenarios for EF. Such applications require low level SQL approach.