コード例 #1
0
        public void SeedIdentifier(LMSDBContext context)
        {
            var courseCategories = new[]
            {
                new CourseCategory()
                {
                    IDNumber = "CS01",
                    Name     = "Test 1"
                },
                new CourseCategory()
                {
                    IDNumber = "CS02",
                    Name     = "Test 2"
                },
                new CourseCategory()
                {
                    IDNumber = "CS03",
                    Name     = "Test 3"
                },
            };

            context.CourseCategories.AddRange(courseCategories);

            context.SaveChanges();
        }
コード例 #2
0
        public void SeedEverything(LMSDBContext context)
        {
            context.Database.EnsureCreated();

            if (context.Members.Any())
            {
                return; // Db has been seeded
            }

            SeedIdentifier(context);
        }
コード例 #3
0
        //private readonly Dictionary<int, Employee> Employees = new Dictionary<int, Employee>();
        //private readonly Dictionary<int, Supplier> Suppliers = new Dictionary<int, Supplier>();
        //private readonly Dictionary<int, Category> Categories = new Dictionary<int, Category>();
        //private readonly Dictionary<int, Shipper> Shippers = new Dictionary<int, Shipper>();
        //private readonly Dictionary<int, Product> Products = new Dictionary<int, Product>();

        public static void Initialize(LMSDBContext context)
        {
            var initializer = new LMSDBInitializer();

            initializer.SeedEverything(context);
        }