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

EF Core does not report types it failed to load from migration assemblies #19691

Closed
Trojaner opened this issue Jan 24, 2020 · 3 comments · Fixed by #32577
Closed

EF Core does not report types it failed to load from migration assemblies #19691

Trojaner opened this issue Jan 24, 2020 · 3 comments · Fixed by #32577
Assignees
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug

Comments

@Trojaner
Copy link

Trojaner commented Jan 24, 2020

EntityFramework Core should report failed types from SharedTypeExtensions.GetLoadableDefinedTypes.

I just spent 6 hours figuring out why EntityFramework Core suddenly does not apply any pending migrations with context.Database.Migrate(). After exploring more I noticed that context.Database.GetMigrations() and context.Database.GetPendingMigrations() were empty. I checked IMigrationAssemlby which also had an empty Migrations property.

Finally, after testing and debugging more I noticed that GetLoadableDefinedTypes catches a TypeLoadException without reporting it here. This exception should be reported at least in the debug logs.

It seems like Microsoft.EntityFrameworkCore.Relational was missing for my migrations project for some reason, after adding it my migrations started to work again.

@Trojaner Trojaner changed the title EF Core does not report failed types EF Core does not report types it failed to load from migration assemblies Jan 24, 2020
@ajcvickers
Copy link
Member

@Trojaner It's by design that type loading errors are ignored when scanning assemblies. That being said, logging a warning seems like a good idea.

@ajcvickers ajcvickers added this to the Backlog milestone Jan 24, 2020
@Trojaner
Copy link
Author

Trojaner commented Jan 24, 2020

I agree they should be ignored and not thrown, but reporting such exception would be really helpful

@MWallenberg
Copy link

Thank you @Trojaner , I had the same issue, and spent more than a day trying to debug it. I agree it should be reported or logged somehow.

@ajcvickers ajcvickers modified the milestones: Backlog, 7.0.0 Oct 25, 2021
@ajcvickers ajcvickers removed their assignment Apr 22, 2022
@ajcvickers ajcvickers added propose-punt punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. and removed propose-punt labels Jul 6, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, Backlog Jul 7, 2022
@bricelam bricelam removed their assignment Jul 8, 2023
@ajcvickers ajcvickers self-assigned this Dec 8, 2023
ajcvickers added a commit that referenced this issue Dec 9, 2023
…n types

And allow non-public parameterless constructors.

Fixes #24748
Fixes #19691
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Dec 9, 2023
@ajcvickers ajcvickers modified the milestones: Backlog, 9.0.0 Dec 9, 2023
ajcvickers added a commit that referenced this issue Dec 12, 2023
…n types (#32577)

And allow non-public parameterless constructors.

Fixes #24748
Fixes #19691
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview1 Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants