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

Update Data-Seeding.md #14334

Merged
merged 4 commits into from
Nov 3, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/en/Data-Seeding.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ Then the data seed contributors can access to these properties via the `DataSeed

If a module needs to a parameter, it should be declared on the [module documentation](Modules/Index.md). For example, the [Identity Module](Modules/Identity.md) can use `AdminEmail` and `AdminPassword` parameters if you provide (otherwise uses the default values).

### Separate Units Of Work
maliming marked this conversation as resolved.
Show resolved Hide resolved

The default seed will be in a unit of work and may use transactions. If there are multiple `IDataSeedContributor` or too much data written, it may cause a database timeout error.

We provide an extension method of `SeedInSeparateUowAsync` to create a separate unit of work for each `IDataSeedContributor`.
maliming marked this conversation as resolved.
Show resolved Hide resolved

````csharp
public static Task SeedInSeparateUowAsync(this IDataSeeder seeder, Guid? tenantId = null, AbpUnitOfWorkOptions options = null, bool requiresNew = false)
````

### Where & How to Seed Data?

It is important to understand where & how to execute the `IDataSeeder.SeedAsync()`?
Expand Down Expand Up @@ -163,4 +173,4 @@ We suggest the same way on development. Run the DbMigrator console application w

You probably want to seed the data also for automated [testing](Testing.md), so want to use the `IDataSeeder.SeedAsync()`. In the [application startup template](Startup-Templates/Application.md), it is done in the [OnApplicationInitialization](Module-Development-Basics.md) method of the *YourProjectName*TestBaseModule class of the TestBase project.

In addition to the standard seed data (that is also used on production), you may want to seed additional data unique to the automated tests. If so, you can create a new data seed contributor in the test project to have more data to work on.
In addition to the standard seed data (that is also used on production), you may want to seed additional data unique to the automated tests. If so, you can create a new data seed contributor in the test project to have more data to work on.