Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.EntityFrameworkCore;
- namespace StudentMeal.Models
- {
- public class ApplicationDbContext : DbContext
- {
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- optionsBuilder.UseSqlServer(
- @"Server=localhost;Database=StudentMeal;Trusted_Connection=true;");
- }
- public DbSet<Meal> Meals { get; set; }
- public DbSet<Student> Students { get; set; }
- public DbSet<MealStudent> MealStudent { get; set; }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Student>().HasData(
- new Student()
- {Name = "Tom Schoonbeek", Email = "cleanstream@gmail.com", Phonenumber = "0123456789", Id = 1001},
- new Student()
- {Name = "Tom Smits", Email = "sniffmans@hotmail.com", Phonenumber = "9876543210", Id = 1002},
- new Student()
- {Name = "Sjoerd Schepers", Email = "SS@gmail.com", Phonenumber = "0621316473", Id = 1003});
- modelBuilder.Entity<Meal>().HasData(
- new Meal
- {
- MaximumParticipants = 5,
- StudentId = 1001,
- Name = "Nasi Goreng",
- DayPrepared = new DateTime(2018, 9, 24, 18, 30, 0),
- Price = 10.00,
- Description = "Lekkere nasi mhmm",
- Id = 1001
- },
- new Meal()
- {
- MaximumParticipants = 5,
- StudentId = 1001,
- Name = "Spagetthi Bolognese",
- DayPrepared = new DateTime(2018, 9, 23, 18, 0, 0),
- Price = 8.50,
- Description = "Spagetthi",
- Id = 1002
- },
- new Meal()
- {
- MaximumParticipants = 5,
- StudentId = 1003,
- Name = "Pasta Carbonara",
- DayPrepared = new DateTime(2018, 9, 18, 17, 30, 0),
- Price = 2.50,
- Description = "Goedkoop en lekker",
- Id = 1003
- },
- new Meal()
- {
- MaximumParticipants = 5,
- StudentId = 1003,
- Name = "Aardappelen",
- DayPrepared = new DateTime(2018, 10, 25, 18, 00, 0),
- Price = 7.50,
- Description = "Van Hollandschen bodem",
- Id = 1004
- },
- new Meal()
- {
- MaximumParticipants = 5,
- StudentId = 1003,
- Name = "Pannenkoeken",
- DayPrepared = new DateTime(2018, 9, 15, 17, 30, 0),
- Price = 15.00,
- Description = "Lekkere pannenkoeken mhmm",
- Id = 1005
- }
- );
- modelBuilder.Entity<MealStudent>().HasData(
- new MealStudent() {MealId = 1001, StudentId = 1002, Id = 1},
- new MealStudent() {MealId = 1001, StudentId = 1003, Id = 2},
- new MealStudent() {MealId = 1001, StudentId = 1001, Id = 3},
- new MealStudent() {MealId = 1002, StudentId = 1002, Id = 4},
- new MealStudent() {MealId = 1002, StudentId = 1003, Id = 5},
- new MealStudent() {MealId = 1002, StudentId = 1001, Id = 6},
- new MealStudent() {MealId = 1003, StudentId = 1002, Id = 7},
- new MealStudent() {MealId = 1003, StudentId = 1003, Id = 8},
- new MealStudent() {MealId = 1003, StudentId = 1001, Id = 9},
- new MealStudent() {MealId = 1005, StudentId = 1002, Id = 10},
- new MealStudent() {MealId = 1005, StudentId = 1003, Id = 11},
- new MealStudent() {MealId = 1005, StudentId = 1001, Id = 12},
- new MealStudent() {MealId = 1004, StudentId = 1002, Id = 13},
- new MealStudent() {MealId = 1004, StudentId = 1003, Id = 14});
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement