I am trying to implement the following dynamic tableName using Dependency Injection, but I am getting the error
The type arguments for method DbContext.Set(string) cannot be inferred from the usage
Does anyone have an answer or another suggestion to create dynamic entity names?
var tableName = "Table1";
Type returnType;
switch (tableName)
{
case "Table1":
returnType = typeof(Table1EntityType);
break;
case "Table2":
returnType = typeof(Table2EntityType);
break;
}
var query = _context.Set(returnType) -- error occurs here