0

Am building an MVC5 application with Code first approach. The problem i have is that if i run the main migrations for the application models(not for identity models), then the Identity tables cannot be created when the database is already existing and has a __migrationhistory table. If i try to run a query on any of the identity tables, it will return an error that the table doesn't exist. I have searched around but all i could see are the ones talking of adding asp.net identity to an existing database first design.

If i run the identity migrations first before every other thing, it goes well but the main application entity migration will not be effected once the database has been created by the Identity framework, resulting in 'table does not exist' when i try to run any query.

How do i run either the Identity framework migration first and then run the normal entity framwork migration or vice versa. If either can be triggered automatically after the other has completed, it will be fine.

Please any suggestion will be appreciated.

  • You could simplify your life greatly if you have your application context [inherit from the IdentityDbContext](http://stackoverflow.com/questions/19902756/asp-net-identity-dbcontext-confusion). Otherwise you need to deal with multiple contexts and migrations as described [here](http://stackoverflow.com/questions/11197754/entity-framework-one-database-multiple-dbcontexts-is-this-a-bad-idea). – Steve Greene Jan 12 '17 at 21:36
  • Thanks for your comment. I deviced a maybe unconventional but a simple means to solve this. I will post what i did as my answer later on. – Henry Otuadinma Jan 13 '17 at 13:08

0 Answers0