Try something like this (pseudo code, I might forget the names of some methods):
public void Update(Customer entity) { using (MyContext ctx = new MyContext()) {
This code uses the Stub Entity trick. You can, if you have a relationship, you need to tell EF more about the source object, check out the blog post above because you can do this with stubs too.
Alternatively, if you don't care about concurrency at all, you can simply do this:
public void Update(Customer entity) { using (MyContext ctx = new MyContext()) {
Hope this helps
Alex james
Entity Framework Tips
Alex james
source share