Open Closed

Executing Data Seeds in a Specific Order(Including OpenIddictDataSeedContributor #4161


User avatar
0
anil_ozat created
  • ABP Framework version: v6.0.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hello, We are working on a project where we might require multiple different seeders for our database. However, when i run the command 'dotnet run' from DbMigrator, conflicts occur. Mainly, Data about users are tried to br used before user seed data can be defined. To solve this, i have tried the solution in the link below: https://github.com/abpframework/abp/issues/2417 This solution works for the seeders i have defined myself, but when i include the 'OpenIddictDataSeedContributor', dotnet run command generates an error. I have also modified the OpenIddictDataSeedContributor a bit to solve this problem, and the picture uploaded will be that version. The codes, and the error generated are given below.

  1. The data seeder defined by us:

  2. The OpenIddictDataSeedContributor:

  3. The code where all dataseeds will be run:

  4. The error we get when executing 'dotnet run':

We hope to hear From You Soon.


7 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    obiect reference rot set to an instance ot an object.

    Can you try to debug the code to see which object is null?

  • User Avatar
    0
    anil_ozat created

    I have tried this. However, i could not trigger any brakpoints when running dotnet run from the terminal. Is there another way of debugging?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can debug the code on Visual Studio.

  • User Avatar
    0
    anil_ozat created

    I tried different debugging methods, but unfortunately I was unable to get my debugger to trigger any breakpoints. Can you specify what type of debugging should be done? Maybe There are some settings I may not know or haven't tried.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Did you set the breakpoints and Debug the DbMigrator in Visual Studio?

  • User Avatar
    0
    anil_ozat created

    Hello. Sorry for the late response. I tried some other methods. In the end, i tried inserting the highlighted lines in the first picture into the code. Doing so generated the result in the second picture.

  • User Avatar
    0
    alper created
    Support Team Director

    Hello. Sorry for the late response. I tried some other methods. In the end, i tried inserting the highlighted lines in the first picture into the code. Doing so generated the result in the second picture.

    @Anil, no need to do this. Create your own DataSeeders, these will run one by one (not random) also you can create a new empty EF Core migration dotnet ef migrations add MyNewMigration. And write your SQL inserts here in the empty migration file, write T-SQL inserts...

    public partial class Insert_Into_MyTable : Migration
    {
    	protected override void Up(MigrationBuilder migrationBuilder)
    	{
    		migrationBuilder.Sql(@"INSERT INTO MyTable .....");
    	}
    }
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11