private static void SeedData(TxtXContext context) { string books = File.ReadAllText(@"./SampleData/dbo.Books.data.sql"); string listings = File.ReadAllText(@"./SampleData/dbo.Listings.data.sql"); string users = File.ReadAllText(@"./SampleData/dbo.AspNetUsers.data.sql"); context.Database.ExecuteSqlCommand(books); context.Database.ExecuteSqlCommand(users); context.Database.ExecuteSqlCommand(listings); }
public static void InitializeData(TxtXContext context) { context.Database.Migrate(); ClearData(context); SeedData(context); }
public static void ClearData(TxtXContext context) { context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[Books]"); context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[Listings]"); context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[AspNetUsers]"); }
public DbInitializer(TxtXContext context) { _context = context; }