Finbuckle.MultiTenant icon indicating copy to clipboard operation
Finbuckle.MultiTenant copied to clipboard

Design Time Instantiation Finbuckle V9 MultiTenantIdentityDbContext

Open goforebroke opened this issue 1 year ago • 5 comments

In Finbuckle V8 the MultiTenantIdentityDbContext had a constructor that accepted an ITenantInfo object. In V9 the constructors for MultiTenantIdentityDbContext only accept IMultiTenantContextAccessor<> objects, which broke my design time instantiation.

Do you have any examples of design time instantiation with MultiTenantIdentityDbContext for V9? If not I am sure I will get something working later today...

goforebroke avatar Dec 11 '24 21:12 goforebroke

Hi, there is now a factory Create method on MultiTenatDbContext that should let you spin up an instance easily for an IDesignTimeDbContextFactory<T> implementation. Does that work for you?

AndrewTriesToCode avatar Dec 11 '24 23:12 AndrewTriesToCode

Hi Andrew...

It sure did... Should have looked at the updated documentation...

public sealed class IdentityApiDbContextDesignFactory : IDesignTimeDbContextFactory<MultiTenantIdentityDbContext>
{
    public MultiTenantIdentityDbContext CreateDbContext(string[] args)
    {
        const string connectionString = "Server=.; THE REST OF THE CONNECTION STRING;";
        var optionsBuilder = new DbContextOptionsBuilder<IdentityApiDbContext>();
        optionsBuilder.UseSqlServer(connectionString);

        var dbContext = MultiTenantDbContext.Create<MultiTenantIdentityDbContext, AppTenantInfo>(new AppTenantInfo(), optionsBuilder.Options);

        return dbContext;
    }
}

I was then able to build a migration and apply it

goforebroke avatar Dec 11 '24 23:12 goforebroke

This issue has been labeled inactive because it has been open 30 days with no activity. This will be closed in 7 days without further activity.

github-actions[bot] avatar Mar 21 '25 02:03 github-actions[bot]

edit: No this will not be closed--sorry about that!

AndrewTriesToCode avatar Mar 21 '25 05:03 AndrewTriesToCode

This issue has been labeled inactive because it has been open 180 days with no activity. Please consider closing this issue if no further action is needed.

github-actions[bot] avatar Sep 22 '25 02:09 github-actions[bot]