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

PendingModelChangesWarning when migrating from .NET 8 to .NET 9 with multitenancy per schema #35182

Closed
dziedrius opened this issue Nov 22, 2024 · 3 comments

Comments

@dziedrius
Copy link

There are several issues reported related to PendingModelChangesWarning, but our case is quite unique, hence I've decided to open separate issue.
I did quite isolated repro: https://github.com/dziedrius/migration-efcore-9-issue (it is in .NET 8 currently, so that it would be possible to see how behavior changes after migrating to .NET 9)

What I was able to figure out:
So as long as EF Core does not support multitenancy per schema (kind of sad, as in my opinion that is one of the clearest way to do multitenancy), we did it ourselves, it needed custom code, but kind of manageable (strongly influenced by https://github.com/Oriflame/EFCoreMultitenantSample).

The problem is, that schema is applied to migration operations just during runtime, meaning that when migrator is checking diff for source/target models, it sees different schema and hence throws the exception, seems that this check was introduced in .NET 9.

I could not figure out how I could get better control over this, so used the only workaround I knew - disabled warning, and not sure if that is a good way to approach - as I'm loosing ability to get a warning when real model mismatches will appear.

Include provider and version information

EF Core version:
Database provider: (e.g. Npgsql.EntityFrameworkCore.PostgreSQL)
Target framework: (e.g. .NET 9.0)

@cincuranet
Copy link
Contributor

Dupe of #35158.

@cincuranet cincuranet closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2024
@AndriySvyryd
Copy link
Member

Disabling the warning is the correct approach in this case.

@roji
Copy link
Member

roji commented Dec 6, 2024

Note: we've just published #35285 which provides more background and explanations around the new PendingModelChangesWarning; anyone still having trouble should go read that - hopefully it should help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants