-
Notifications
You must be signed in to change notification settings - Fork 110
0. Techniques
Bilal edited this page Aug 14, 2017
·
2 revisions
You can save data using entity framework in 2 ways
public ActionResult Save(BlogViewModel blogViewModel)
{
Blog blog = _dbContext.Blogs.Find(blogViewModel.Id);
blog.Description = blogViewModel.Description;
blog.Title = blogViewModel.Title;
_dbContext.SaveChanges();
return View();
}
public ActionResult Save(Blog blog)
{
_dbContext.Blogs.Attach(blog);
_dbContext.Entry(blog).State = EntityState.Modified;
_dbContext.SaveChanges();
return View();
}
In this pattern, TEDB wont work by default. You will have to set
GlobalTrackingConfig.DisconnectedContext = true;
on application startup.