EntityFrameworkCore.TemporalTables icon indicating copy to clipboard operation
EntityFrameworkCore.TemporalTables copied to clipboard

Multiple of the same Owned type causes exception with Update-Database

Open RedDeathGitHub opened this issue 4 years ago • 1 comments

I want to use multiple of the same type as owned type. Something like:

class Compay {
    public Contact Contact1 { get; set; }
    public Contact Contact2 { get; set; }
}

Contact is configured to be owned type, with .OwnsOne(...).

When I call modelBuilder.UseTemporalTables() (without this call, it all works)

then during Update-Database I get this exception:

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.EntityFrameworkCore.RelationalEntityTypeExtensions.GetTableName(IEntityType entityType) at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlBuilder1.BuildTemporalTableSqlFromEntityTypeConfiguration(IEntityType entityType, Boolean appendSeparator) at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlBuilder1.BuildTemporalTablesSqlForEntityTypes(IEnumerable1 entityTypes, Boolean appendSeparator) at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlBuilder1.BuildTemporalTablesSql(Boolean appendSeparator) at EntityFrameworkCore.TemporalTables.Sql.TemporalTableSqlExecutor1.Execute() at EntityFrameworkCore.TemporalTables.Migrations.TemporalTableMigrator1.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) Object reference not set to an instance of an object.

RedDeathGitHub avatar Oct 19 '20 05:10 RedDeathGitHub

Hi @findulov , please have a look!

RedDeathGitHub avatar Oct 19 '20 05:10 RedDeathGitHub