question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seed data for tenant database

See original GitHub issue

I create a class name InitialBillingGuideLineCreator to seed data to tenant database. I call it in DefaultTenantBuilder like this public void Create() { CreateDefaultTenant(); // Seed BillingGuideLine new InitialBillingGuideLineCreator(_context).Create(); } But it only seed data to host database. Please give me instruction how to seed to tenant’s database. Thank for your support.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ryancyqcommented, Aug 27, 2018

You shouldn’t inject DbContext into TenantAppService.

As @acjh pointed out, you can insert InitialBillingGuideLineCreator() in TenantAppService.cs

e.g.

// Assign admin user to role!
CheckErrors(await _userManager.AddToRoleAsync(adminUser, adminRole.Name));

// your seed method
InitialBillingGuideLineCreator(tenant);

await CurrentUnitOfWork.SaveChangesAsync();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tenant migrations & seeds
How to run migrations for specific or all tenants. ... The same way works for seeding only in the tenant Id 1 website....
Read more >
How to seed data for Tenant when it is created for the first ...
Hi, I'm trying to seed data in the TenantAppService.Create method. The IAbpZeroDbMigrator interface do not provide the expected method:.
Read more >
Data Seeding | Documentation Center | ABP.IO
It is typical to check database if the seeding data is already present. ... this value while inserting data or performing custom logic...
Read more >
Migrations and seeds - Tenancy
Run migrations after a database is created; Run seeds after the database is created ... you might want to seed the database with...
Read more >
How do you seed data? : r/dotnet
Database seeding is populating a database with an initial set of data. It's common to load seed data such as initial user accounts...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found