public static void Initialize(LeerkrachtContext context) { context.Database.EnsureCreated(); if (!context.Leerkracht.Any()) { var lk = new Leerkracht() { Id = 0, FirstName = "Nick", LastName = "Van Acker", Gender = "M", Email = "blablaba@hotmail", IpAddress = "192.168.0.110", Number = "049294003", Postcode = 2600, Street = "JoskeStraat" }; context.Leerkracht.Add(lk); context.SaveChanges(); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, LeerkrachtContext lkContext) { if (env.IsDevelopment()) { DBInitializer.Initialize(lkContext); app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseAuthentication(); app.UseHttpsRedirection(); app.UseMvc(); }