Open Closed

[Bug] - Migration error after framework update #4110


User avatar
0
trannguyenphucanh created
  • ABP Framework version: v5.3.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
  • Database: MySQL WorkBench 8.0.30"

Hi Support Team,

I've tried to create a dozen of tables using code-first EF Core, there're 2 tables having foreign key to abpusers table.

I created domain classes, declared them in DbContextModelCreatingExtensions as well as in DbContext , ran add-migration command, a migration file was created. After that, I ran DbMigratorproject, an issue appeared:

1.Failed to open the referenced table 'appuser': I solved this one by manually modifying the migration file, changed parameter name in table.ForeignKey() and principalTable from AppUser to AbpUsers at the 2 tables having foreign key.

Then I ran the add-migration command again, another issue appeared:

2.Referencing column 'UserId' and referenced column 'Id' in foreign key constraint 'FK_my_table_AbpUsers_UserId' are incompatible.: I also solved this one by manually deleting parameter collation: "ascii_general_ci"at columns UserIdin the file and ran the command again. All worked well.

But, is there any way to remove the collation: "ascii_general_ci param and just uses the default type when migration file is generated? I notice this param is automatically added after the framework is updated to v5 (.NET 5 => .NET 6).

I've tried an answer from stackoverflow but didn't work.

Also, I really appreciate if there's any solid solution for the 1st issue.

Hope to hearing from you guys soon.


2 Answer(s)
  • User Avatar
    0
    trannguyenphucanh created

    Hi, is there any update?

    I tried to put modelBuilder.UseGuidCollation(string.Empty); in DbContextModelCreatingExtensions instead of DbContext and run migration, the parameter collations for newly created column are all disappeared, which is good, but it also alters current columns collation:

    Because current columns use default collation, their collation parameter shouldn't be added, and surely not ascii_general_ci.

    Could you guy take a look at this?

  • User Avatar
    0
    maliming created
    Support Team

    hi

    It seems you didn't use standard abp project.

    We can't give you much advice.

    We need the full steps to reproduce the issue.

Made with ❤️ on ABP v9.1.0-rc.1. Updated on January 17, 2025, 14:13