Base solution for your next web application
Open Closed

Upgrading from AspNetZeroCore v3.4.0 to v4.0.0 #3223


User avatar
0
rickwheeler created

Hi,

What are you suggestions for upgrading from v3.4.0 to v4.0.0?

I seem to have been able to update all of my source code just fine. The issue I have is with the database.

Since you've swapped from EF6 to EFCore, this has caused a major problem as there is a missing migration.

It appears that between 3.4.0 and 4.0.0 of AspNetZero that there were a lot of database changes. Since the EntityFrameworkCore project assumes there is no existing database and only includes an Initial migration I have no real way to upgrade my database which is on v3.4.0.

The changes seem to include the removal of some tables, column additions to some entities such as user, changes to indexes and more.

Do you have any suggestions for how to accomplish upgrading the database?

Thanks.


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    These are the database changes, you can apply them to your database.

    New Tables

    • AbpRoleClaims * AbpUserTokens * __EFMigrationsHistory

    Changed Tables

    > AbpUsers
         * NormalizedEmailAddress: UPPER case of EmailAddress.
         * NormalizedUserName: UPPER case of UserName.
         * ConcurrencyStamp
        
    > AbpRoles
         * NormalizedName: UPPER case of Name.
         * ConcurrencyStamp
        
    

    Deleted Tables * __MigrationHistory

    Thanks.

  • User Avatar
    0
    rickwheeler created

    Thank you. I was able to figure out what these were via SQL schema compare but it is good to have it confirmed.

    I also was able to figure out that if you follow the process below, you can create migrations to handle this upgrade

    • Remove all code from the up and down methods of the Initial_Migration.cs
    • run update-database
    • Delete all the code from the Initial_Migration.Designer.cs and the DbContextModelSnapshop.cs related to the tables and columns you mentioned above
    • Run add-migration V340ToV400
    • This migration should include the code to add the missing tables and columns
    • Add the following code to the bottom of the up method to set the normalized fields to the correct values
    migrationBuilder.Sql("UPDATE AbpUsers SET NormalizedUserName = UPPER(UserName)");
    migrationBuilder.Sql("UPDATE AbpUsers SET NormalizedEmailAddress = UPPER(EmailAddress)");
    migrationBuilder.Sql("UPDATE AbpRoles SET NormalizedName = UPPER(Name)");
    
    • run update-database
  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks for sharing your experince @rickwheeler :).