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

New database seeder approach for EFCore. #25087

Closed
wants to merge 3 commits into from
Closed

Conversation

AshkanAbd
Copy link

New database seeder approach for EFCore.
Seeder placed in EFCore\Seeder directory
Please check readme and sample project for more details.
DatabaseSeederExtension.cs:

  • The extension for IServiceCollection to setup and process seeders.
    SeederAttribute.cs:
  • The Attribute that determine seeder methods in project. Add this attribute to the method that you want to act as a seeder.
    IDatabaseSeeder.cs:
  • The interface which runs seeder methods and seeds database.
  • Use EnsureSeeded method for seeding database. Note that seeders should not run in a dotnet-ef process.
  • Use SetEnvironment to run only production seeds or both development and production seeds.
    DatabaseSeeder.cs:
  • The class that implements IDatabaseSeeder.
    SeederInfo.cs:
  • The class that holds informations about seeder during seeding database.

DatabaseSeederExtension.cs:
- The extension for IServiceCollection to setup and process seeders.
SeederAttribute.cs:
- The Attribute that determine seeder methods in project. Add this attribute to the method that you want to act as a seeder.
IDatabaseSeeder.cs:
- The interface which runs seeder methods and seeds database.
- Use EnsureSeeded method for seeding database. Note that seeders should not run in a dotnet-ef process.
- Use SetEnvironment to run only production seeds or both development and production seeds.
DatabaseSeeder.cs:
- The class that implements IDatabaseSeeder.
SeederInfo.cs:
- The class that holds informations about seeder during seeding database.
@roji
Copy link
Member

roji commented Jun 14, 2021

Could be related to #14922

- Fix possible null pointers
DatabaseSeeder.cs:
- Fix possible null pointers
InvalidSeederMethodException.cs:
- The exception thrown for invalid seeders.
@AndriySvyryd
Copy link
Member

@AshkanAbd It seems that this PR was opened by error on the official EF Core repo.

If this isn't the case then open an issue with a detailed design and wait for approval before submitting another PR.

@AshkanAbd
Copy link
Author

As @roji said this PR related to #14922 and ef core seed design.
@AndriySvyryd take a look at this comment, it's really painful. Seeds are placed in migrations and you have to create migration for your seeds and seeds will be a part of your migrations. also current seed design won't increase the primary key and indexes of tables. And there is no difference between development seeds and production seeds.
Related issue was created before and I put details for suggested design in readme.md.
Do I need to create an issue for this new design?

@roji
Copy link
Member

roji commented Jun 15, 2021

@AshkanAbd yes - for anything non-trivial, users need to submit a design proposal so that things can be discussed and agreed-upon, preferably before coding starts. See our contribution guide.

@roji
Copy link
Member

roji commented Jun 15, 2021

The readme.md is the general description of what EF Core is, and is shown on the Github repo page for EF Core. That's definitely not the right place for a design proposal etc.

@AshkanAbd
Copy link
Author

Sorry I forget to create a new branch for it. I will create an issue for it.

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

Successfully merging this pull request may close these issues.

3 participants