MattHoneycutt / Fail-Tracker

Fail Tracker is an agile issue tracking system written with ASP.NET MVC.
MIT License
136 stars 60 forks source link

ApplicationDbContext getting created multiple times per request #8

Closed luisgizirian closed 8 years ago

luisgizirian commented 8 years ago

During the PS course, you show how to get a single creation/dispose thanks to the Container-Per-Request pattern.

But, cloning this repo, overriding Dispose (exactly as you show), setting up breakpoints (exactly as you show) and running the site, I get these latter to being hit several times per request.

(although the creation & dispose is correctly balanced)

Am I missing something or there's something going on here?

MattHoneycutt commented 8 years ago

Are you hitting the Accounts controller? If so, that one is intentionally not set up to use IoC to illustrate what happens without a container-per-request, so a request to it will indeed cause multiple contexts to be created.

luisgizirian commented 8 years ago

You're right @MattHoneycutt! Sorry about that.