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

Struggling with EF Core and Seeding data #851

Open
MarkLFT opened this issue Jul 8, 2024 · 2 comments
Open

Struggling with EF Core and Seeding data #851

MarkLFT opened this issue Jul 8, 2024 · 2 comments
Labels

Comments

@MarkLFT
Copy link

MarkLFT commented Jul 8, 2024

I have spent the last four days trying to make an API multi-tenant. But am getting nowhere fast. I read the documentation and have read dozens of articles. It looked straightforward to use finbuckle with EF Core.

I am using configuration store and header plus static configuration. I am using database per tenant and using .net core 8 and DI.

Is there a working sample including seeding the database anywhere?

Most of the time I am getting null for the tenant in onconfiguring.

@AndrewTriesToCode
Copy link
Contributor

Hi @MarkLFT

let me ask you a few questions to help.

  1. db aside are things working as expected? For each request does the tenant resolution work ok?

  2. are you seeing null tenant in the database during api requests, during your app startup/seeding, or both?

  3. are you using migrations and if so are you seeing the issue there?

@MarkLFT
Copy link
Author

MarkLFT commented Jul 8, 2024

Without finbuckle the api works correctly.

If I login to the api it seems to see be resolving correctly, bit as I can't get the seeding to work I have no user data in the dB I can't complete the login to test correctly.

My immediate issue is seeding the database. At the start if the seeding routine I am populating the assessor with a tenant, and that seems to work. But when I get a dB context the connection string is not getting loaded, unless I load it manually.

Then when the new user services are called, and it instantiates another dB context using DI the connection string is null again.

I am guessing using finbuckle with ef core, and seeding all the tenants is a very common scenario, so an upto date sample would be very useful.

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