Skip to content

RewriteName Errors With Views That Has Keys #279

Description

@mattmentrup

Core 6
Oracle.EntityFrameworkCore 6
EFCore.NamingConvention, Latest on NuGet.org

Naming Convention Used:
UsedSnakeCaseNamingConvetion,
UseUpperSnakeCaseNamingConvention

During the OnModelCreating(ModelBuilder), when configuring the modelBuilder with a View and that view has keys defined, the RewriteName function throws an 'object reference not set to an instance of an object' error.

OnModelCreating(builder) {
  builder.EnsureSchema("abc"); // I do not believe this matters, but just in case for testing.

  builder.Entity<DTOEntity>(ef => {
    ef.ToView("xyz");
    ef.HasKey(e => new { e.Key1, e.Key2 }); // Throws error on this line.
  }
}

Interestingly enough, when declaring the ToView after the HasKey method, the error above is not thrown.

For example, the below snippet does not cause the error to occur.

OnModelCreating(builder) {
  builder.EnsureSchema("abc"); // I do not believe this matters, but just in case for testing.

  builder.Entity<DTOEntity>(ef => {
    ef.HasKey(e => new { e.Key1, e.Key2 });
    ef.ToView("xyz");
    // No error is thrown and the extension is happy.
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions