This video shows how to use EF Core Migrations with SQLite in MAUI Project.
Migrations cannot be used inside MAUI project directly. The solution is to put the DbContext and Models in a seperate Class Library project.
1. Create MAUI Project
2. Create Class Library Project and create inside it the Models and the DbContext.
3. Reference the class library project from the MAUI project.
4. Add the DbContext in MauiProgram.cs and reference the class library as the Migrations assembly.
5. Run the program.
– When adding migrations, reference the project and startup project as follow:
dotnet ef migrations add Initial –startup-project ..MauiSqliteClassLibrary –project ..MauiSqliteClassLibrary