abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.97k stars 3.45k forks source link

Guidance Needed for Changing Primary Key from Guid to Long in ABP Framework Pre-built Features #20558

Open asammad48 opened 3 months ago

asammad48 commented 3 months ago

We are facing challenges in changing the primary key from Guid to long in ABP's pre-built features, such as User Management and Roles Management. We are planning to use the ABP Framework with an existing database. Although we have attempted several approaches, including extending the AbpUser class and overriding the primary key, these methods have not been successful. We also tried customizing the ABP User and Identity modules, but this requires extensive code modifications.

Could you please suggest an effective way to change the primary key from Guid to long in these pre-built features, so we can utilize ABP's Identity Management and Feature Management seamlessly?

Thank you.

asammad48 commented 3 months ago

Unable to create a 'DbContext' of type ''. The exception 'Unable to determine the relationship represented by navigation 'AppUser.CreatorUser' of type 'AppUser'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

I am getting this error. When adding a migration

asammad48 commented 3 months ago

` base.OnModelCreating(builder);

    /* Include modules to your migration db context */

    builder.Entity<AppUser>(b =>
    {
        b.ToTable("AbpUsers");
        b.ConfigureByConvention();
        b.HasOne<IdentityUser>().WithOne().HasForeignKey<AppUser>(x => x.Id);
    });

    builder.ConfigurePermissionManagement();
    builder.ConfigureSettingManagement();
    builder.ConfigureBackgroundJobs();
    builder.ConfigureAuditLogging();
    builder.ConfigureIdentity();
    builder.ConfigureOpenIddict();
    builder.ConfigureFeatureManagement();
    builder.ConfigureTenantManagement();`

public class AppUser : AbpUser { public override long Id { get; set; } public long ExistingDbID { get; set; } public string Title { get; protected set; } = "";

public int Reputation { get; protected set; }

}

mackwan84 commented 2 months ago

Any updates? We are facing the same problem that uses the ABP Framework with an existing database