Finbuckle / Finbuckle.MultiTenant

Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
https://www.finbuckle.com/multitenant
Apache License 2.0
1.26k stars 261 forks source link

ASP NET Web Api - Applying Separate Databases approach - Unable to create a 'DbContext' of type 'AppDbContext'. #852

Closed gitruhul closed 2 weeks ago

gitruhul commented 2 weeks ago

Recently,

I was doing R&D on Multi Tenancy and I found the package finbuckle

and felt it is useful for my team members.

I created this repo https://github.com/gitruhul/FinBuckleMultiTenantSamples for the demo purpose.

For the Separate Databases scenario, I have updated AppDbContext.cs and trying to generate migration scripts using the command

dotnet ef migrations add InitialCreate -c AppDbContext

I am getting the error

Unable to create a 'DbContext' of type 'AppDbContext'. The exception 'No database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

I may be missing something here. It would be great for my team if someone can guide me on this.

gitruhul commented 2 weeks ago

I may need to read more to get this working. Closing for now.