I want to make an EFCore migration for a MAUI Blazor app. But when using Package Manager or CLI i get an error because startup project targets Android. I do not see this error in the tutorials i am following.
Migrations cannot be used inside MAUI project directly. The solution is to put the DbContext and Models in a separate Class Library project.
When adding migrations, reference the project and startup project as follow:
dotnet ef migrations add Initial --startup-project ..\YourClassLibrary --project ..\YourClassLibrary
Credits to Asaad Iaaly: https://github.com/AssadIaaly/MauiSqlite
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With