Seed Roles And Users To An Existing Database In ASP.NET MVC 5 Using Identity
Hello, In this tutorial, I will demonstrate seeding roles and users to an existing database in an ASP.NET MVC 5 application using Identity framework. For simplicity, I will use a Northwind. This database doesn't have membership tables at all. To begin with, accomplish the steps below: 1. Create an ASP.NET MVC application and then change web.config connectionStrings element to connect to an existing database (Northwind as my example). 2. Under Package Manager Console type PM> Enable-Migrations 3. Under Package Manager Console type PM> Add-Migration ASPMembership * This will create a file Timespan_ASPMembership.cs inside Migrations folder with scripts to create Membership Tables such as AspNetUsers, AspNetRoles and etc. 4. Under Package Manager Console type PM> Update-Database * This will add membership tables to Northwind database. 5. To seed Roles and Users, create a class SeedRolesAndUsers.cs inside Models folder. This class referenc...