Open Closed

How to set seed admin data for new microservice solution? #9712


User avatar
0
48949912 created

Check the docs before asking a question: https://abp.io/docs/latest Check the samples to see the basic tasks: https://abp.io/docs/latest/samples The exact solution to your question may have been answered before, and please first use the search on the homepage.

Provide us with the following info: 🧐 Hint: If you are using the ABP Studio, you can see all the information about your solution from the configuration window, which opens when you right-click on the solution and click on the Solution Configuration button.

  • Exception message and full stack trace:
  • Steps to reproduce the issue:

4 Answer(s)
  • User Avatar
    -1
    AI-Bot created
    Support Team ABP Agent
    • To seed admin data (such as the default admin user) in a new ABP microservice solution, you should use the DbMigrator project provided in the solution. The DbMigrator is responsible for applying database migrations and seeding initial data, including admin user and roles.

    • Running the update-database command in the Package Manager Console only applies migrations and does not seed data. You must run the DbMigrator project to perform both migration and data seeding.

    • If you want to customize the seeded admin user (email, password, etc.), you can modify the SeedDataAsync method in your DbMigrator project. Pass custom properties (like "AdminEmail" and "AdminPassword") to the DataSeedContext:

    await _dataSeeder.SeedAsync(
          new DataSeedContext(tenant?.Id)
              .WithProperty("AdminEmail", "youradmin@yourdomain.com")
              .WithProperty("AdminPassword", "YourSecurePassword123!")
      );
    
    • This ensures that the admin user is created with your specified credentials during the seeding process.

    • For microservice solutions, make sure each service that requires initial data has its own data seed contributor, and always run the DbMigrator after adding a new microservice to ensure all necessary data is seeded.

    • Do not override or duplicate the default data seed contributors unless you need to change the default behavior. If you do, ensure you replace the original service as documented in ABP's dependency injection guide.

    Sources:

    • https://abp.io/support/questions/4
    • https://abp.io/support/questions/894

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    48949912 created

    I can not find DbMigrator project provided in the microservice solution?

  • User Avatar
    0
    48949912 created

    The microservice solution created by ABP Studio.

  • User Avatar
    0
    48949912 created

    I have already solved!

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 12, 2025, 10:20