protected void CreateDbContext() { DbContext = new RequestDbContext(); //Do Not enable proxy entities DbContext.Configuration.ProxyCreationEnabled = false; //Load navigation property explicitly DbContext.Configuration.LazyLoadingEnabled = false; DbContext.Configuration.ValidateOnSaveEnabled = false; }
public virtual void Update(Request entity) { //var dbEntityEntry = _Context.Entry(entity); //if (dbEntityEntry.State != EntityState.Detached) //{ // _Context.Requests.Attach(entity); //} //dbEntityEntry.State = EntityState.Modified; using (var context = new RequestDbContext()) { context.Set <Request>().Attach(entity); context.ChangeTracker.Entries <Request>().First(e => e.Entity == entity) .State = EntityState.Modified; context.SaveChanges(); } }
public RequestRepository() { _Context = new RequestDbContext(); }