Index created on views do not get scaffolded properly
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Start with the reported path through RelationalIndexExtensions.GetDatabaseName() and CSharpDbContextGenerator.tt; the issue says view-mapped entities have no table name, so the generated HasIndex call gets a null name despite index metadata retaining it. Trace the existing design-time scaffolding tests for indexes on views and add coverage for the reported materialized-view case. Done means scaffolding preserves the index name and the generated context model loads successfully.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug description
@roji @ErikEJ
This is a followup on original issue https://github.com/dotnet/efcore/issues/37345
Since that issue is closed, I couldn't reopen it.
I understand that the Oracle scenario was identified earlier in https://github.com/dotnet/efcore/issues/37345 as a separate issue. We have retested it with an Oracle EF Core 11 development build, and the null-index-name problem still reproduces.
Actual behavior and impact
Applying scaffolding using above table, materialized view, and index on the materialized view, the generated configuration still contains:
modelBuilder.Entity<MatViewDemo1>(entity =>
{
entity.HasNoKey().ToView("MAT_VIEW_DEMO_1");
entity.HasIndex(e => e.StringCol1, null);
});
This is not only missing metadata: accessing the generated context's Model throws:
System.ArgumentNullException: Value cannot be null. (Parameter 'name')
at EntityTypeBuilder<TEntity>.HasIndex(..., String name)
Investigation
Boundary logging shows:
- The Oracle provider returns a
DatabaseViewcontaining correctly namedDatabaseIndexobjects and the correct columns. RelationalScaffoldingModelFactorypreserves the name in the EF index metadata:index.Nameis non-null.- The materialized-view entity is mapped using
ToView(...), with no table mapping. RelationalIndexExtensions.GetDatabaseName()returnsnullwhenGetTableName()is null.CSharpDbContextGenerator.ttusesindex.GetDatabaseName()directly as the namedHasIndexargument, resulting inHasIndex(..., null).
This appears to be a gap at the shared relational/design-time code-generation boundary, rather than incorrect Oracle index discovery.
Request
Could you please investigate and fix the scaffolding path so that a index supplied for a view-mapped entity produces valid configuration and preserves its name?
For the example in the https://github.com/dotnet/efcore/issues/37345, the expected configuration would be:
entity.HasIndex(e => e.StringCol1, "MAT_VIEW_DEMO_1_INDEX1");
Your code
Please find the complete scenario in https://github.com/dotnet/efcore/issues/37345
Stack traces
Verbose output
EF Core version
11.0.0
Database provider
No response
Target framework
No response
Operating system
No response
IDE
No response
- Lenguaje dominante
- C#
- Estrellas
- 14.8k
- Forks
- 3.4k
- Merge medio
- 3 d 18 h
- PR fusionados (30 d)
- 159
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/efcore
-
customer-reported
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 2 días
-
Regression in 11.0: replacing an owned instance or re-adding an entity with the same key sets unchanged OnAdd properties to nullPosiblemente ocupada @seragAhmed la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
dotnet/efcore#39617 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
customer-reported
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 2 días
Todos los issues de dotnet/efcore
Issues similares
-
bug emitter:client:csharp
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
microsoft/typespec#12572 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
needs-area-label
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
AWS Lambda: KeyNotFoundException drops HTTP-triggered transactions when allowAllHeaders is disabledAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
newrelic/newrelic-dotnet-agent#3949 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area-networking
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/aspnetcore#70545 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día