Open Closed

Migration 4.2.1 to 4.3: error when regenerate entities with navigation properties AppUserId #1343


User avatar
0
christophe.baille created
  • ABP Framework version: v4.3.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace: The property 'AppUser.ExtraProperties' could not be mapped because it is of type 'ExtraPropertyDictionary', which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

I started to migrate a soution from 4.21 to 4.3, then I did notice that when I regenerate entities of my solution, it was creating index and FK to my navigation properties. As it is a good improvement I wanted to regenerate all entities.

It works well for all my entites except the one which have Navigation properties "AppUserId".

I got a long error message (see attachment bellow), the most important seems this:

The property 'AppUser.ExtraProperties' could not be mapped because it is of type 'ExtraPropertyDictionary', which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

I see this line added on MyProjectDbContextModelCreatingExtensions, into builder.Entity<MyExistingEntity>

b.HasOne<AppUser>().WithMany().HasForeignKey(x => x.AppUserId);

I see some posts about it: https://github.com/abpframework/abp/issues/927 https://github.com/abpframework/abp/issues/1414 https://github.com/abpframework/abp/issues/1517 https://github.com/abpframework/abp/issues/2746

But YourDbContextModelCreatingExtensions.cs is modified by ABP suite just before trying to "generate" my migration script, so I can not test the suggestions

I did some tests and noticed that the error is coming from this line

NOTE: I put a comment to a similar question (without mentionning that it is realted to the update), as it is open since 2 weeks and still not assigned, I post it here.

https://support.abp.io/QA/Questions/1263/abp-suite---AppUser-as-navigation-property-is-not-working

Thanks for your help.


28 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Delete the DbContextModelCreatingExtensions will work.

  • User Avatar
    0
    alper created
    Support Team Director

    Suite works with 4.4.X without any issues (even with unified DbContexts explained here). The issue you face is; You added your project before this migration and migrated your project manually. But Suite still doesn't know the correct DbContext file path. To correct this open Suite and remove the solution (this will not delete any of your entities and metada of your entities) And then add the same solution again. This time Suite will find the correct DbContext file.


    Alternatively, you can open the Suite database from %UserProfile%\.abp\suite\appsettings.json and fix the following nodes:

    • DbContextModelCreatingExtensionsFilePath
    • MigrationsMigrationsDbContext
  • User Avatar
    0
    christophe.baille created

    The issue have been fixed a month ago with liangshiwei.

    As he mentionned:

    Delete the DbContextModelCreatingExtensions will work.

    I just forgot to comfirm... Sorry for th convenience

Made with ❤️ on ABP v9.1.0-preview. Updated on November 18, 2024, 05:54