public void CreateTemporalTable()
        {
            using (var context = DatabaseHelpers.CreateContext())
            {
                // Arrange/Act
                var id = Guid.NewGuid();

                context.People.Add(new Context.Person
                {
                    Id   = id,
                    Name = "Dazza"
                });

                context.SaveChanges();

                var person = context.People.SingleOrDefault(x => x.Id == id);
                person.Name = "MadDawg";

                context.SaveChanges();

                // Assert
                var historic = context.People.FromSql("SELECT * FROM [dbo].[People_History]").ToList();
                Assert.IsTrue(context.People.Any());
                Assert.IsTrue(historic.Any());
            }
        }
Example #2
0
    public void Setup()
    {
        using (var connection = ConnectionFactory.Create("master"))
        {
            if (connection.DatabaseExists(ConnectionFactory.DefaultDatabaseName))
            {
                connection.DropDatabase(ConnectionFactory.DefaultDatabaseName);
            }

            var context = DatabaseHelpers.CreateContext();
            context.Database.Migrate();
        }
    }
 public DatabaseContext CreateDbContext(string[] args)
 {
     return(DatabaseHelpers.CreateContext());
 }