public static void Initialize(EventDbContext context) { context.Database.EnsureCreated(); if (context.Events.Any() || context.Attendees.Any() || context.Organizers.Any()) { return; } /*context.Database.EnsureCreated(); * context.RemoveRange(context.Attendees); * context.RemoveRange(context.Events); * context.RemoveRange(context.Organizers);*/ var attendees = new Attendee[] { new Attendee { Name = "Albert Krimson", Phone_Number = 0793123456, Email = "*****@*****.**" }, new Attendee { Name = "Svante Pålsson", Phone_Number = 0793123456, Email = "*****@*****.**" }, new Attendee { Name = "Tom Nordbeck", Phone_Number = 0793123456, Email = "*****@*****.**" }, new Attendee { Name = "Lana Lane", Phone_Number = 0793123456, Email = "*****@*****.**" }, new Attendee { Name = "Alan Weik", Phone_Number = 0793123456, Email = "*****@*****.**" }, new Attendee { Name = "Civil Polis", Phone_Number = 0793123456, Email = "*****@*****.**" }, }; context.Attendees.AddRange(attendees); context.SaveChanges(); var events = new Event[] { new Event { Place = "Stockholm Stadion", Date = 14 / 7 - 2021, Description = "The Doors, live concert", Spots_Available = 200 }, new Event { Place = "02 Arena", Date = 14 / 7 - 2021, Description = "Khruangbin, live concert", Spots_Available = 0 }, new Event { Place = "Etihad Stadium", Date = 14 / 7 - 2021, Description = "Tame Impala, live concert", Spots_Available = 20 }, new Event { Place = "Camp Nou", Date = 14 / 7 - 2021, Description = "Soccer match, Barcelona FC vs Real Madrid FC", Spots_Available = 2000 }, }; context.Events.AddRange(events); context.SaveChanges(); var organizers = new Organizer[] { new Organizer { Name = "Real Records", Phone_Number = 043123156, Email = "*****@*****.**" }, new Organizer { Name = "Thai Events", Phone_Number = 043122456, Email = "*****@*****.**" }, new Organizer { Name = "Groovy Records", Phone_Number = 043123456, Email = "*****@*****.**" }, new Organizer { Name = "Tickermaster", Phone_Number = 043123454, Email = "*****@*****.**" }, }; context.Organizers.AddRange(organizers); context.SaveChanges(); }
public MyEventsModel(ASP.NET_Inlämningsuppgift1.Data.EventDbContext context) { _context = context; }