Testing ASP.NET Core series: fixed seed IDs so the app starts on EF Core 10 - #2253
Merged
vladimir-pecanac-main merged 1 commit intoSep 27, 2026
Conversation
…ore 10
Every folder seeded its two employees with Guid.NewGuid() in HasData, so on
EF Core 9 and later the app's startup Migrate() threw PendingModelChangesWarning
("The model for context 'EmployeeContext' changes each time it is built") and
never reached the database. The tests stayed green because they skip migrations.
The seed rows now use the GUIDs the InitialMigration and the model snapshot
already record (Mark 07e57250-..., Evelin 195430d1-...), the same values in all
six folders. Nothing else changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All six folders of
dotnet-testing/AspNetCoreTestingSeriesseeded their two employees withGuid.NewGuid()inHasData. On EF Core 9 and later that makes the app's startupMigrate()throwPendingModelChangesWarning("The model for context 'EmployeeContext' changes each time it is built") before it connects, soEmployeesAppcould not start against SQL Server in any folder. The tests stayed green because they never run migrations.The fix replaces the two random IDs with the GUIDs the
InitialMigrationandEmployeeContextModelSnapshotalready record, the same values in every folder:07e57250-5443-4bdc-be13-59239ada918e195430d1-9227-451e-8378-65df427be580Nothing else changes (12 lines in six
EmployeeContext.csfiles).Checked locally on .NET SDK 10.0.302, EF Core 10.0.11:
StartingProjectagainst SQL Server Express: before the change the app dies with the warning above; after it,InitialMigrationapplies, both rows land with those IDs, and/Employees/Indexreturns 200 listing Mark and Evelin.