c# - Accssess to repository from .net core library -


i need wrap function in repository class in .net core library. mistake constructor doesn't have constructor. doing wrong? here dbcontext code

 public class effmerccontext : dbcontext {     public dbset<department> departments { get; set; }     public dbset<employee> employees { get; set; }     public dbset<project> projects { get; set; }     public effmerccontext(dbcontextoptions<effmerccontext> options)         : base(options)     {     } }      public class effmercdbcontextfactory : idbcontextfactory<effmerccontext> {     public effmerccontext create(dbcontextfactoryoptions options)     {         var builder = new dbcontextoptionsbuilder<effmerccontext>();         builder.usesqlserver("server=(localdb)\\mssqllocaldb;database=pinchdb;trusted_connection=true;multipleactiveresultsets=true");         return new effmerccontext(builder.options);     } } 

my repository class far

public class employeerepository {     public employee getbyid(int id)     {         using (effmerccontext db = new effmerccontext())         {          }     } } 

you can modify employeerepository following...

public class employeerepository {     var optionsbuilder = new dbcontextoptionsbuilder<effmerccontext>();     // add necessary options     public employee getbyid(int id)     {         using (effmerccontext db = new effmerccontext(optionsbuilder.options))         {          }     } } 

to learn more can follow this


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -