Compiled model: generate a deterministic model ID
Maintainer thường phản hồi trong vòng 2 ngà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
- 35/100
Hướng nghiên cứu
Read the compiled model code generator, especially CSharpRuntimeModelCodeGenerator, and trace how Model.ModelId is emitted. The issue proposes deriving the ID from generated code, but does not name tests or specify how to handle hashing and generation order; first inspect existing compiled model tests and their ModelId baseline setup. Done means unchanged model input generates the same ID and changed model input generates a different ID.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What problem are you trying to solve?
The compiled model code generator writes a random model ID on every run:
private MyContextModel()
: base(skipDetectChanges: false, modelId: new Guid("11e036cd-643f-f23b-4e7b-adf20935ed15"), entityTypeCount: 473)
Model gets its ID from Guid.NewGuid() and CSharpRuntimeModelCodeGenerator writes model.ModelId as a literal. So running dotnet ef dbcontext optimize on an unchanged model always changes *ModelBuilder.cs.
That is annoying when the compiled model is committed to source control:
- every regeneration gives a diff, even when nothing changed;
- a CI check "is the compiled model up to date?" (regenerate and compare) can't be done without masking the ID first;
- two developers regenerating on separate branches always get a merge conflict on that line.
EF Core's own tests work around it: CompiledModelTestBase sets ModelId = new Guid() to get stable baselines.
Describe the solution you'd like
Derive the model ID from the generated code (e.g. a SHA-256 hash of all generated files) instead of the random ID of the design-time model.
The ID is only used in memory (as a cache key, e.g. in ValueGeneratorCache), so it only has to differ between different models. A hash of the generated code does that, and gives the same output for the same model.
I have a draft PR for this.
- Ngôn ngữ chính
- C#
- Star
- 14.8k
- Fork
- 3.5k
- Merge trung bình
- 2 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 158
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
-
Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with TakeCó thể đã có người làm @Mohamedadel-prog đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
dotnet/efcore#39848 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
customer-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
customer-reported
Độ 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
-
Độ khó 4/5 3-5 ngày 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ự
-
area-VM-meta-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
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 82/100
microsoft/sqltoolsservice#2851 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
elsa-workflows/elsa-foundation#6322 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
mohebifar/made-in-iran#273 ·