private void initializeDabases(IApplicationBuilder app) { createSqliteDbFile(); // In-case that we need to do some migrations. using (var scope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { ApplicationDbContext applicationDbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); if (applicationDbContext.Database.GetPendingMigrations().Any()) { applicationDbContext.Database.Migrate(); } EventyDbContext eventyDbContext = scope.ServiceProvider.GetRequiredService <EventyDbContext>(); if (eventyDbContext.Database.GetPendingMigrations().Any()) { eventyDbContext.Database.Migrate(); } SeedData.Initialize(scope.ServiceProvider.GetRequiredService <IServiceProvider>()); } }
private static void seedFamilyMembers(EventyDbContext eventyDbContext) { if (eventyDbContext.FamilyMembers.Any()) { return; } if (!File.Exists(@"Seeds/familymembers.json")) { return; } if (!eventyDbContext.FamilyMembers.Any()) { Console.WriteLine("Seeding family members..."); var familyMembers = JsonConvert.DeserializeObject <List <FamilyMember> >( File.ReadAllText(@"Seeds/familymembers.json") ); eventyDbContext.FamilyMembers.AddRange(familyMembers); eventyDbContext.SaveChanges(); } }
private static void seedEventsFamilies(EventyDbContext eventyDbContext) { if (eventyDbContext.EventsFamilies.Any()) { return; } if (!File.Exists(@"Seeds/eventsfamilies.json")) { return; } if (!eventyDbContext.EventsFamilies.Any()) { Console.WriteLine("Seeding eventsfamilies..."); var eventsFamilies = JsonConvert.DeserializeObject <List <EventsFamilies> >( File.ReadAllText(@"Seeds/eventsfamilies.json") ); eventyDbContext.EventsFamilies.AddRange(eventsFamilies); eventyDbContext.SaveChanges(); } }
public FamiliesRepository(EventyDbContext eventyDbContext) { EventyDbContext = eventyDbContext; }
public FamilyMemberController(EventyDbContext context) { _context = context; }
public EventsFamilyMembersController(EventyDbContext context) { Context = context; }
public EventController(EventyDbContext context) { _context = context; }