-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Construct IDesignTimeDbContextFactory without first discovering all DbContext types #27322
Comments
Hi guys. We are migrating from .NET 3.1 to .NET 6, and we'd like to use EF6 as well. However, the issue mentioned here #27306 and here #9076 makes the experience of adding migrations really frustrating... As I understand current issue (Constructing IDesignTimeDbContextFactory without first discovering all DbContext types) should resolve it for us. So hopefully it will be done soon. Do you have any timeline for this? Thanks! |
@Andrey-Ignatenko We're considering it for EF8. We have added a static flag indicating design-time in EF7, which should help if code is currently running at design time that should not. |
…ignTimeDbContextFactory implementations are found. Throw for MSBuild-based execution if no DbContext types are found. Fixes #27322
…ignTimeDbContextFactory implementations are found. Throw for MSBuild-based execution if no DbContext types are found. Fixes #27322
…ignTimeDbContextFactory implementations are found. Throw for MSBuild-based execution if no DbContext types are found. Fixes #27322
…ignTimeDbContextFactory implementations are found. Throw for MSBuild-based execution if no DbContext types are found. Fixes #27322
Currently, services are discovered before creating any IDesignTimeDbContextFactory instance. This ensures that we get the correct DbContext type when multiple may be registered, possibly from different assemblies. However, this is problematic when the context factory is being used as an escape hatch for something that is failing in service discovery--for example, see #27306 and comments on #9076.
To fix this, we could do an initial search using some heuristics. For example, we could search for
IDesignTimeDbContextFactory
implementations and if there is only one found for one context type which matches the context type specified on the command line, then use it with no further discovery.The text was updated successfully, but these errors were encountered: