Skip to content

Instantly share code, notes, and snippets.

View fabianmadurai's full-sized avatar

Fabian Madurai fabianmadurai

  • South Africa
View GitHub Profile
@fabianmadurai
fabianmadurai / gist:2bba2aec150a041d36c233686e24531c
Created July 20, 2019 11:18
Reverse Poco Generator with existing DB Asp.NET MVC 5 Template in Visual Studio 2015
If you want to use Reverse Poco generator with an existing database, then its easier to script (see below) the asp.net identity tables inside
your application DB. Then you can use Reverse Poco generator and connect to the DB and get the POCOs for both your own data tables
and the Identity Tables you created.
If you are using the MVC template, then name your dbContext the same as what mvc does, (which is ApplicationDbContext).
you also need to comment out the MVC templates ApplicationDbContext that is found in the IdentityModels.cs file.
in that context, there is a create method. copy that method and put it inside your reverse Poco Generator db context class.
and then all the Identity code in the template should work.
The goal of all of this was to just get the 5 tables that Identity creates for you , inside your application DB. and then wire up the DbContext code.
SQL Script to create the Identity Tables. you can also create a migration and add this SQL into the migration so that it will be versioned