Skip to content

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

@RedDeathGitHub

Description

@RedDeathGitHub

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions