Index created on views do not get scaffolded properly
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- C#
- スター
- 14.8k
- フォーク
- 3.4k
- 平均マージ
- 3日 18時間
- マージ済み PR(30日)
- 159
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/efcore のほかの issue
-
customer-reported
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 2 日以内に返信
-
Regression in 11.0: replacing an owned instance or re-adding an entity with the same key sets unchanged OnAdd properties to null対応中かも @seragAhmed が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
dotnet/efcore#39617 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
customer-reported
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
bug emitter:client:csharp
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/typespec#12572 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
AWS Lambda: KeyNotFoundException drops HTTP-triggered transactions when allowAllHeaders is disabledオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
newrelic/newrelic-dotnet-agent#3949 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-networking
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/aspnetcore#70545 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信