Dynamically Instantiate Model object in Entity Framework DB first by passing type as parameter

Viewed 7755

Have a requirement to create instance of Entity Framework generated Model class dynamically by passing table name as parameter (Model generated in DB first approach and using EF 6.0)

like,

// Input Param
string tableName 

// Context always same
DBContext dbContext= new DBContext(); 

//Need to create object query dynamically by passing 
//table name from front end as below  

 IQueryable<"tableName"> query = dbContext."tableName ";

Need to pass 100+ tables as input param and structure of all table is same.

Please help.

1 Answers
Related