DuendeSoftware / Support

Support for Duende Software products
21 stars 0 forks source link

Migration script is not correct for SessionDbContext -- Server Side Sessions with EF Core #751

Closed JeremyVm closed 1 year ago

JeremyVm commented 1 year ago

Which version of Duende BFF are you using? 2.0.0

Which version of .NET are you using? net 6.0

I'm trying to create the migrations for use with serversidesessions stored in ef core. When I try to create the migration I only get the migration history part, not the UserSessions Table.

This is my code in my Blazor WASM Server side Program.cs:

builder.Services .AddBff(options => options.EnableSessionCleanup = true) .AddEntityFrameworkServerSideSessions(options => options.UseSqlServer(configuration.GetConnectionString("IdentityServer"))) .AddRemoteApis();

In my CLI I run: dotnet ef migrations script --idempotent

This is my output:

IF OBJECT_ID(N'[EFMigrationsHistory]') IS NULL BEGIN CREATE TABLE [EFMigrationsHistory] ( [MigrationId] nvarchar(150) NOT NULL, [ProductVersion] nvarchar(32) NOT NULL, CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId]) ); END; GO

I'm doing something wrong. Just don't know what for the moment.

josephdecock commented 1 year ago

This looks like the EF migrations are not in a good state. I recommend that you go back to the previous version of Duende.BFF and reset your migrations so that you have a good snapshot of where you're migrating from, following these docs. Then upgrade your BFF and try again to generate a migration.

JeremyVm commented 1 year ago

I think everything was ok. Apparently you have to first create the migrations itself and then you can make the call to make the scripts.

I was not aware of this. The issue can be closed.