Now in this article we will create I will show you how to create our initial data in our database.
Create a new folder inside the Data folder and call it DataInitializer.
Then inside the DataInitializer folder, add a new class and name it UserAndRoleDataInitializer.
UserAndRoleDataInitializer have only one public method which is the SeedData method. It accepts UserManager and RoleManger as parameter and use it to create our user and roles. The code itself is pretty straight forward. We just check if the role already exist if not we will create. The same apply for the user.
Anjali Punjab is a freelance writer, blogger, and ghostwriter who develops high-quality content for businesses. She is also a HubSpot Inbound Marketing Certified and Google Analytics Qualified Professional.
CheapHostingASP.NET is designed to help ASP.NET beginners and experts. The site was founded in 2014 by Anjali, Ethan, Sarah and Robert, who are professional ASP.NET geeks. Our experts have been evaluating many hosting companies for many years. The business aims to provide people with better products at cost-effective prices.