views:

53

answers:

1

I am developing application using Entity Framework.

When i'm in debugging mode my test values are saved into database when i exit debugging even if i'm not hitting SaveChanges method.

Why is this happening?

I spent 4 hours trying to figure it out, but had no luck....

Even if i have my breakpoint at the start of the action, and i exit debugger right away - data still persisting...

A: 

Well, it turns out that debugger continues execution of code even when it is on a breakpoint, and if there is no errors in my code it will apply changes to the database.

one way to avoid this - is to add preprocessor to your code like this:

#if !DEBUG 
      context.SaveChanges();
#endif

I was not able to track it via SavingChanges method, as am not really sure what should i look for there, there are so many different things, and i didn't have enough time to stuck on that.

Sasha