c# - Adding entities sets dynamically in dbcontext the repository layer doesnt compile -


my dbcontext code similar this:

public class mydbcontext : dbcontext, imydbcontext {    public dbset<customer> customers { get; set; }    public dbset<product> products { get; set; }   ... } 

and want add dbsets in dbcontext dinamically, code similar this:

protected override void onmodelcreating(dbmodelbuilder modelbuilder) {     var baseassemblyname = "namespace.web.model";     var assemblytype = appdomain.currentdomain.getassemblies().firstordefault(x => x.fullname.equals(baseassemblyname));      //culture class defined in assembly entity models reside     var typestoregister = assemblytype.gettypes()         .where(type => type.namespace != null && type.namespace.equals(baseassemblyname))         .where(type => type.basetype.isgenerictype && type.basetype.getgenerictypedefinition() == typeof(entitytypeconfiguration<>));      foreach (var type in typestoregister)     {         dynamic configurationinstance = activator.createinstance(type);         modelbuilder.configurations.add(configurationinstance);     } } 

but not executing, put breakpoint in beggining of method , @ point there building errors in repository layer uses example:

public icustomer get(int id) {     return db.customers.find(id); } 

what can create dinamically entities in dbcontext?

thanks!


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -