Question

I have a asp.net web application that uses Entity Framework. The application data layer uses a method outlined by Jordan Van Gogh found here. In a nutshell, this method uses one shared objectcontext instance per http request and is disposed of using a AspNetObjectContextDisposalModule that inherits IHttpModule.

I have added another project, a few additional tables, and setup a data layer that copies (exactly) the example I described above to my application. This additional project and subsequent different data model all work perfectly. I can perform different operations using the 2 data layers with seemingly no consequences. Of course the objectsets are different in the 2 data layers as they represent different tables.

My question is this:

Is this approach a good idea? I get most of what is going on behind the scenes but both of these models use System.Data.Objects.ObjectContext. If user A performs an operation using the first data layer while simultaneously user B performs an operation using the second data layer, are there going to be problems with the "shared" objectcontext?

Thanks. And be gentle.

Edit Note: I am using different oc keys

Was it helpful?

Solution

You should be OK:

  • The object context is per http request so the context from different users will not interfere with each other
  • Each context updates different tables so they will not interfere with each other

One thing that you may have to watch out for is what happens it two users update the same data at the same time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top