Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
1
Indexable
Never
protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            var companyList = new Company[]{
                new Company {CompanyId = 1, Name = "PXL Smart ICT", Address = "Elfde Liniestraat 24", Zip = "3500", City = "Hasselt"},
                new Company {CompanyId = 2, Name = "Datasense", Address = "Kempische Steenweg 309 Bus 1.01", Zip = "3500", City = "Hasselt"}
            };
            modelBuilder.Entity<Company>().HasData(companyList);

            var supervisorList = new Supervisor[]
            {
                new Supervisor("Tom"),
                new Supervisor("Jan"),
                new Supervisor("Pieter")
            };
            modelBuilder.Entity<Supervisor>(s =>
            {
                s.HasKey(b => b.SupervisorId);
                s.Property(b => b.SupervisorId).ValueGeneratedOnAdd();
            });
            modelBuilder.Entity<Supervisor>().HasData(supervisorList);

            //var studentList = new Student[]
            //{
            //    new Student("Jan Smets"),
            //    new Student("Bram Steukers"),
            //    new Student("Pieter Bormans")
            //};
            //modelBuilder.Entity<Student>().HasData(studentList);
        }
    }