private string GetTemporalTableSqlDependingOnIfTableIsTemporalOrNot <TEntity>( ITableHelper <FakeDataContext> tableHelper, params Type[] entityTypesToCreateTemporalTablesFor) where TEntity : class { var options = DbContextOptionsSetup.Setup <FakeDataContext>(); using (var context = new FakeDataContext(options)) { // Register entity types to support temporal tables. entityTypesToCreateTemporalTablesFor ?.ToList() ?.ForEach(e => TemporalEntitiesCache.Add(context.Model.FindEntityType(e))); var entityType = context.Model.FindEntityType(typeof(TEntity)); var temporalTableSqlBuilder = new TemporalTableSqlBuilder <FakeDataContext>( context, new TemporalTableSqlGeneratorFactory(), tableHelper); string sql = temporalTableSqlBuilder.BuildTemporalTablesSqlForEntityTypes(new[] { entityType }); return(sql); } }
public void AddTemporalTableTest() { var options = DbContextOptionsSetup.Setup <FakeDataContext>(); using (var context = new FakeDataContext(options)) { var entityType = context.Model.FindEntityType(typeof(User)); // Add entity type. TemporalEntitiesCache.Add(entityType); // Test if the entity type exists in the cache. Assert.IsTrue(TemporalEntitiesCache.IsEntityConfigurationTemporal(entityType)); } }