The reason this exception is probably thrown is because there is a problem creating ApplicationDbContext .
In my case, I added Migrations and installed
Database.SetInitializer(new MigrateDatabaseToLatestVersion<ApplicationDbContext, Configuration>());
And I started to get the same error as you.
It turned out that when I tried to access any object in the database, DbContext threw an error saying that AspNetUsers already exist, since I had previously run my code without activating the migration, so a database was created with all the correct tables needed for Identity , and as soon as I did EnableMigrations and installed the initializer, it threw an error saying that the table already exists.
In your case, I assume that there are some basic problems with ApplicationDbContext, before starting, try the following methods before Config.Auth:
var ctx = new ApplicationDbContext(...); var count = ctx.Users.Count();
See if it returns an invoice or throws an exception.
Michal Ciechan Jan 31 '15 at 19:48 2015-01-31 19:48
source share