namespace QuizFactory.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using QuizFactory.Data;

    internal sealed class Configuration : DbMigrationsConfiguration<QuizFactoryDbContext>
    {
        public Configuration()
        {
            this.AutomaticMigrationsEnabled = true;
            this.AutomaticMigrationDataLossAllowed = false;
        }

        protected override void Seed(QuizFactoryDbContext context)
        {
            if (!context.Roles.Any())
            {
                var seedUsers = new SeedUsers();
                seedUsers.Generate(context);
            }
            
            var seedData = new SeedData(context);
            if (!context.QuizDefinitions.Any())
            {
                foreach (var item in seedData.Quizzes)
                {
                    context.QuizDefinitions.Add(item);
                }
            }

            if (!context.Categories.Any())
            {
                foreach (var item in seedData.Categories)
                {
                    context.Categories.Add(item);
                }
            }

            context.SaveChanges();
        }
    }
}
namespace QuizFactory.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using QuizFactory.Data;

    internal sealed class Configuration : DbMigrationsConfiguration<QuizFactoryDbContext>
    {
        public Configuration()
        {
            this.AutomaticMigrationsEnabled = true;
            this.AutomaticMigrationDataLossAllowed = true;
        }

        protected override void Seed(QuizFactoryDbContext context)
        {
            if (!context.Roles.Any())
            {
                var seedUsers = new SeedUsers();
                seedUsers.Generate(context);
            }
            
            var seedData = new SeedData(context);
            if (!context.QuizDefinitions.Any())
            {
                foreach (var item in seedData.Quizzes)
                {
                    context.QuizDefinitions.Add(item);
                }
            }

            if (!context.Categories.Any())
            {
                foreach (var item in seedData.Categories)
                {
                    context.Categories.Add(item);
                }
            }

            context.SaveChanges();
        }
    }
}
Revert "disable automatic migration data loss"
Revert "disable automatic migration data loss"

This reverts commit f6024ca8c0657cab4eeda90ef9225f66654fd6be.
