Entity Framework 6 not saving changes

asp.net-mvc-5 c# entity-framework-6 savechanges

Accepted Answer

ZZZ_tmp
0
7/6/2017 11:06:50 AM

Popular Answer

Please modify your code slightly and try the following: Use the following instead of db.Advance Bookings.Add(ab):

db.Entry(ab).State = EntityState.Added;

As far as I can tell, this issue can only arise if the DbContext is detached since it isn't throwing any errors. Consider enclosing your code in a using block.

using (var ab = new DbContext()) 
{
//instantiate the object and saveChanges.
}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow