Entity Framework Db.SaveChanges() not working?

entity-framework, savechanges

Solution

If you are using two different instances of the `DbContext` (the `db` variable as you named it) then nothing will be saved when you call `SaveChanges` on a context different than the one where your entities are tracked. You need to use the Attach method first.

db.customer_images.Attach(item);
db.SaveChanges();

However I think in your case you can avoid the attach step if you refactor a bit you code and don't use the DbContext from the entity itself.

Problem

Can u tell me what is the problem?

Original source