Creating EF Core Migrations in .NET MAUI Blazor | SharpLines


Creating migrations in a .NET MAUI app can be a challenge. The biggest error I came across was “Startup project targets platform ‘Android’. The Entity Framework Core Package Manager Console Tools don’t support this platform.” This video will brief developers on how to successfully initialise and migrate a database designed for use in a .NET MAUI Blazor application, using a class library project and a DbContextMigrationFactory.

Source Code ➔

0:00 Working example
0:14 Issue when creating migrations
0:37 Creating Entity & Shared Class Library projects
0:51 Moving DbContext and Models to new Entity project
1:00 Linking the projects together
1:15 Adding EFCore Nuget Packages to Entity project
1:35 Creating DbContextMigrationFactory
2:34 Creating a path to save the database to
3:49 Adding a model to the DbContext
3:58 Adding a migration to the database using the DbContextMigrationFactory
4:29 Updating the database using the DbContextMigrationFactory to apply the migration to the database
4:41 Working example

#webdevelopment #blazor #webassembly #dotnet #csharp #entityframeworkcore #efcore #sqlite