Index created on views do not get scaffolded properly
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- C#
- Star
- 14.8k
- Fork
- 3.4k
- Merge trung bình
- 3 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 159
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/efcore
-
customer-reported
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Regression in 11.0: replacing an owned instance or re-adding an entity with the same key sets unchanged OnAdd properties to nullCó thể đã có người làm @seragAhmed đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
dotnet/efcore#39617 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
customer-reported
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của dotnet/efcore
Issue tương tự
-
bug emitter:client:csharp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/typespec#12572 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
AWS Lambda: KeyNotFoundException drops HTTP-triggered transactions when allowAllHeaders is disabledĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
newrelic/newrelic-dotnet-agent#3949 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-networking
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/aspnetcore#70545 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
Maintainer thường phản hồi trong vòng 1 ngày