I have a problem with EF 4.1. We found a performance issue in the project in one method, I started using dotTrace for resolving the issue, and I’ve found such strange behavior:

When application starts – everything is ok, first calls to the method work fine but later the time spent in Monitor.Enter grows each time I perform some actions on site.
I understand that the problem is with locking, and it means that something blocks the calls, but I don’t have any idea what is happening there. If I had sources of the EF 4.1 I could try to debug the whole thing, but it’s the last thing I would do.
Could you please give me some tips where to look, and what can probably influence such behavior? The first thing I thought are transactions of course but I couldn’t find any transactions used in this project, at least explicitly!
You’re welcome to write any idea you have, cause I can’t find any similar issue on the internet.
Thank you.
I’ve found an issue in our code. It was, as always, small cause that had huge impact on everything.
As I’ve already said, in the application there was strange issue – every call to the MVC application and therefore to the EntityFramework was in separate AppDomain. EF CodeFirst builds and compiles model once per AppDomain and in my case it was building and compiling the model every time, cause it was a separate AppDomain. The cause was simple, someone in other team have added filesystem logging to the assembly that was called, and every call to the class of that assembly changed the file and WebServer was restarting the application. I have just turned off the logging and it fixed the problem. Now I don’t have this performance issue.