Let’s start by adding a DbSeeder.cs static class to the /Data/ folder. This class will use the ApplicationDbContext to create some sample entities and save them to our Database; doing that will take a considerable amount of code, hence it might be useful to split the various class components into #region blocks so that we can better understand the various steps.
Let's start with the Public Methods region, which will contain the methods that we want to make available from external classes:
[...]#region Public Methodspublic static void Seed(ApplicationDbContext dbContext){ // Create default Users (if there are none) if (!dbContext.Users.Any()) CreateUsers(dbContext); // Create default Quizzes (if there are none) together ...