C
C#12mo ago
Davide Dunne

Deploy Blazor Entity Framework code first on IIS

Hello everyone I was asked to deploy a Blazor Application with EF Code First, in order to run the migrations on the server do I have to get all the code and then compile it from the server or can I still run the migration only with the binaries?
1 Reply
Jimmacle
Jimmacle12mo ago
migrations are compiled into the application unless you deleted them you can migrate on startup with code like
await using var db = await app.Services.GetRequiredService<IDbContextFactory<PortalDbContext>>().CreateDbContextAsync();
await db.Database.MigrateAsync();
await using var db = await app.Services.GetRequiredService<IDbContextFactory<PortalDbContext>>().CreateDbContextAsync();
await db.Database.MigrateAsync();

Did you find this page helpful?