Skip to content
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

Closed
Tracked by #22945
ajcvickers opened this issue Jan 31, 2022 · 2 comments · Fixed by #34082
Closed
Tracked by #22945
Labels
area-aspire area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@ajcvickers
Copy link
Contributor

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.

@Andrey-Ignatenko
Copy link

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!

@ajcvickers
Copy link
Contributor Author

@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.

@bricelam bricelam removed their assignment Jul 8, 2023
@AndriySvyryd AndriySvyryd self-assigned this Jun 20, 2024
@AndriySvyryd AndriySvyryd modified the milestones: Backlog, 9.0.0 Jun 20, 2024
AndriySvyryd added a commit that referenced this issue Jun 25, 2024
…ignTimeDbContextFactory implementations are found.

Throw for MSBuild-based execution if no DbContext types are found.

Fixes #27322
@AndriySvyryd AndriySvyryd added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed consider-for-next-release labels Jun 25, 2024
AndriySvyryd added a commit that referenced this issue Jun 25, 2024
…ignTimeDbContextFactory implementations are found.

Throw for MSBuild-based execution if no DbContext types are found.

Fixes #27322
@AndriySvyryd AndriySvyryd removed their assignment Jun 25, 2024
AndriySvyryd added a commit that referenced this issue Jun 25, 2024
…ignTimeDbContextFactory implementations are found.

Throw for MSBuild-based execution if no DbContext types are found.

Fixes #27322
AndriySvyryd added a commit that referenced this issue Jun 25, 2024
…ignTimeDbContextFactory implementations are found.

Throw for MSBuild-based execution if no DbContext types are found.

Fixes #27322
@AndriySvyryd AndriySvyryd removed their assignment Jun 27, 2024
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview7 Aug 21, 2024
@roji roji modified the milestones: 9.0.0-preview7, 9.0.0 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-aspire area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
5 participants