-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
I am looking for an example or help on using views along side temporal tables. My current implementation results in an exception when updating the database.
I have used PreventTemporalTables so that only specific tables are made temporal:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.PreventTemporalTables();
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
SeedDb.Seed(modelBuilder);
}
I have configured my views as follows:
public class OtherEntityStatesConfiguration : IEntityTypeConfiguration<OtherEntityState>
{
public void Configure(EntityTypeBuilder<OtherEntityState> builder)
{
builder.HasNoKey();
builder.ToView("View_OtherEntityStates");
}
}
When I execute dotnet ef database update then I receive this exception:
System.ArgumentNullException: Value cannot be null. (Parameter 'Table name not initialized')
at EntityFrameworkCore.TemporalTables.Sql.Generation.BaseTemporalTableSqlGenerator..ctor(String tableName, String schemaName)
at EntityFrameworkCore.TemporalTables.Sql.Generation.NoSqlTemporalTableGenerator..ctor(String tableName, String schemaName)
at EntityFrameworkCore.TemporalTables.Sql.Factory.TemporalTableSqlGeneratorFactory.CreateInstance(Boolean isEntityConfigurationTemporal, Boolean isEntityTemporalInDatabase, String tableName, String schemaName)
at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlBuilder`1.BuildTemporalTableSqlFromEntityTypeConfiguration(IEntityType entityType, Boolean appendSeparator)
at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlBuilder`1.BuildTemporalTablesSqlForEntityTypes(IEnumerable`1 entityTypes, Boolean appendSeparator)
at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlBuilder`1.BuildTemporalTablesSql(Boolean appendSeparator)
at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlExecutor`1.Execute()
at EntityFrameworkCore.TemporalTables.Migrations.TemporalTableMigrator`1.Migrate(String targetMigration)
at EntityFrameworkCore.TemporalTables.Migrations.TemporalTableMigratorResolver.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
I can see the null check in the constructor that generates the exception but I am not seeing a way to get around it:
public BaseTemporalTableSqlGenerator(string tableName, string schemaName = "dbo")
{
this.tableName = tableName;
this.schemaName = schemaName;
if (string.IsNullOrWhiteSpace(tableName))
{
throw new ArgumentNullException("Table name not initialized");
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels