tjoudeh/JumpStart-MVC6WebApi — pull request #1 by npnelson (2014-11-25 18:45:39+00:00)
Title: Change registrations to Scoped, change connection to localDB, add readme.md

Sorry, I think I probably committed a github foul by taking three different things and combining them into one pull request, so feel free to ignore me:

Anyway, the most important part of this pull request is to change the registrations for IRegistrationRepo and RegistrationDbContext to Scoped from Singleton.

Assuming EF7 DbContexts are not thread safe like their EF6 counterparts (http://stackoverflow.com/questions/6126616/is-dbcontext-thread-safe) then I have confirmed that both IRegistrationRepo and RegistrationDbContext need to be registered as Scoped. Registering the dbcontext as scoped is not enough (as I guessed in my comment posted with the article that references this code).

I confirmed by creating a constructor for RegistrationDbContext (I did not check that change in) and setting a breakpoint on it and then calling the webapi multiple times without shutting it down. The constructor did not get called per webapi request until both were registered as scoped.

I also changed the default connection to use SQL localDB instead of SQL Express. SQL localDB is installed with VS 2015 (I assume it is installed with the SQL Data Tools, so make sure you check that installation option)

More info on localDB can be found here: http://msdn.microsoft.com/en-us/library/hh510202.aspx

Finally, I added a basic Readme.MD file