You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
}
}
The text was updated successfully, but these errors were encountered:
I identified the issue that Microsoft EntityFramework will set the Name value for the key after the entity has been declared as a view to null.
I submitted a PR #280 to handle this fix by adjusting the INameRewriter.RewriteName signature to accept the nullable string value and can return a nullable string value.
@mattmentrup thanks.. I'm very busy right now with other priorities - I traditionally turn my attention to this plugin close to the release time in November, when other components are already frozen etc. Just to set expectations in terms of reviewing etc - but I'll definitely take a look later in the year.
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.Interestingly enough, when declaring the
ToView
after theHasKey
method, the error above is not thrown.For example, the below snippet does not cause the error to occur.
The text was updated successfully, but these errors were encountered: