Search code examples
asp.net-mvciisentity-framework-6

Can Entity Framework run in a web garden with multiple worker processs?


After posting a question earlier, I started to wonder if an Entity Framework model (connecting to multiple databases) could run in a web garden with multiple worker processes? Has anyone attempted this?


Solution

  • Absolutely it can, due to EF's Unit of Work pattern it can work remarkably well in a web garden, it's not the ORM itself though that is a significant factor, it's the style and structure of the business logic that will make the difference.

    One might even go so far as to say that EF is better suited for this than some other frameworks, but that is highly subjective, so we wont go there...

    Unit of Work patterns work really well for REST style or stateless service implementations, if the state is not persisted between requests or across sessions then it is really easy to scale out the service implementation regardless of the framework that you are using to access the database.

    That's not to say that a repository pattern can't be effective across a distributed hosting environment, personally I just find that with EF there is less boilerplate code and less effort to get the job done.

    EF had a slow start, but it has matured into a very stable product, EF.Core looks to be heading in the right direction too ;)