Exemple #1
0
 public static void ClearData(TPContext context)
 {
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[SignInReasons]");
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[SignInCourses]");
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[SignIns]");
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[Courses]");
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[Departments]");
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[Reasons]");
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[People]");
     context.Database.ExecuteSqlCommand("DELETE FROM [dbo].[Semesters]");
 }
Exemple #2
0
        private static void SeedData(TPContext context)
        {
            string courses       = File.ReadAllText(@"..\..\SampleData\dbo.Courses.data.sql");
            string departments   = File.ReadAllText(@"..\..\SampleData\dbo.Departments.data.sql");
            string people        = File.ReadAllText(@"..\..\SampleData\dbo.People.data.sql");
            string reasons       = File.ReadAllText(@"..\..\SampleData\dbo.Reasons.data.sql");
            string semesters     = File.ReadAllText(@"..\..\SampleData\dbo.Semesters.data.sql");
            string signIns       = File.ReadAllText(@"..\..\SampleData\dbo.SignIns.data.sql");
            string signInReasons = File.ReadAllText(@"..\..\SampleData\dbo.SignInReasons.data.sql");
            string signInCourses = File.ReadAllText(@"..\..\SampleData\dbo.SignInCourses.data.sql");

            context.Database.ExecuteSqlCommand(departments);
            context.Database.ExecuteSqlCommand(courses);
            context.Database.ExecuteSqlCommand(people);
            context.Database.ExecuteSqlCommand(reasons);
            context.Database.ExecuteSqlCommand(semesters);
            context.Database.ExecuteSqlCommand(signIns);
            context.Database.ExecuteSqlCommand(signInReasons);
            context.Database.ExecuteSqlCommand(signInCourses);
        }
Exemple #3
0
 public static void InitializeData(TPContext context)
 {
     context.Database.Migrate();
     ClearData(context);
     SeedData(context);
 }
Exemple #4
0
 public DbInitializer(TPContext context)
 {
     _context = context;
 }