Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design Time Instantiation Finbuckle V9 MultiTenantIdentityDbContext #914

Open
goforebroke opened this issue Dec 11, 2024 · 2 comments
Open
Labels

Comments

@goforebroke
Copy link

goforebroke commented Dec 11, 2024

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...

@AndrewTriesToCode
Copy link
Contributor

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?

@goforebroke
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants