fullstackhero / blazor-starter-kit

Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components.
MIT License
3.5k stars 736 forks source link

Enable CLI migration #240

Closed rioda78 closed 3 years ago

rioda78 commented 3 years ago

Describe the bug cannot create migration using CLI, only PMC supported

To Reproduce follow https://codewithmukesh.com/blog/blazor-hero-quick-start-guide/, migrate database using PMC

Expected behavior enable Cli command for migration dan update database

Desktop (please complete the following information):

How to resolve**

  1. remove migration on infrastucture with PMC remove-migration
  2. add migration assembly to dbcontext .AddDbContext<BlazorHeroContext>(options=> options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"), b=>b.MigrationsAssembly("Sipd.Server"))) .AddTransient<IDatabaseSeeder, DatabaseSeeder>(); where SIPD is folder name or namespace
  3. change directory to server and running cli dotnet ef migrations add Initial anc command dotnet ef database update

now CLI is running well thanks for this project

274188A commented 3 years ago

try this:

dotnet ef migrations add --startup-project ..\Server\Server.csproj --context BlazorHeroContext "your comment here..." -o Migrations