Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Add coverage for a loadable provider assembly without DesignTimeProviderServicesAttribute.
1 open finding
What changed in this PR
Improves reverse-engineering errors for providers that do not support scaffolding.
Changes:
- Adds a clear unsupported-provider error.
- Handles missing design-time provider services gracefully.
- Adds tests for unsupported and missing providers.
| File | Reviewed change |
|---|---|
test/EFCore.Design.Tests/Design/Internal/DatabaseOperationsTest.cs |
Tests provider error scenarios. |
src/EFCore.Design/Properties/DesignStrings.resx |
Adds the new error message. |
src/EFCore.Design/Properties/DesignStrings.Designer.cs |
Exposes the localized message. |
src/EFCore.Design/Design/Internal/DesignTimeServicesBuilder.cs |
Handles missing design-time attributes. |
src/EFCore.Design/Design/Internal/DatabaseOperations.cs |
Validates scaffolding service registration. |
Files not reviewed (1)
- src/EFCore.Design/Properties/DesignStrings.Designer.cs: Generated file
🧠 Review effort: Lite
Comment on lines
+175
to
+178
| _reporter.WriteVerbose( | ||
| DesignStrings.CannotFindDesignTimeProviderAssemblyAttribute(provider)); | ||
|
|
||
| throw new InvalidOperationException(message); | ||
| return; |
Contributor
Author
There was a problem hiding this comment.
Added unit test coverage for a loadable provider assembly without DesignTimeProviderServicesAttribute (using Microsoft.EntityFrameworkCore) in commit 4d12e51.
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.

Fixes #14629
Description
When reverse engineering / scaffolding (
Scaffold-DbContext/dotnet ef dbcontext scaffold) with an unsupported database provider (such asMicrosoft.EntityFrameworkCore.Cosmos,Microsoft.EntityFrameworkCore.InMemory, or any provider that does not implement reverse engineering design-time services), the user previously received a cryptic, unhelpfulSystem.InvalidOperationException:Directly analogous to #1652 where
MigrationsOperations.EnsureServiceschecks ifIMigratoris registered and throwsOperationException(DesignStrings.NonRelationalProvider(providerName)):DesignTimeServicesBuilder.ConfigureProviderServices, ifDesignTimeProviderServicesAttributeis missing on the provider assembly, log verbose information and return rather than throwing an internalInvalidOperationException. Missing runtime provider assemblies still throwOperationException(DesignStrings.CannotFindRuntimeProviderAssembly).DatabaseOperations.ScaffoldContext, callEnsureServiceson the scoped service provider to ensureIDatabaseModelFactoryhas been registered. If not registered, throwOperationException(DesignStrings.CannotScaffoldProvider(provider)):The provider '{provider}' does not support reverse engineering.DatabaseOperationsTestverifying that reverse engineering with an unsupported provider throwsOperationExceptionwith the improved error message, and nonexistent provider assemblies continue to report missing provider assemblies.