Base solution for your next web application
Open Closed

Make relation one-to-one with AbpUser from CustomModule #4832


User avatar
0
hitaspdotnet created

Hi, How you can mapping your entities from different assemblies? I have a entity in a class library named ShopModule with a entity named Customer. I want make OTO relation between Customers and AbpUser. A user can be a Customer that not required for all users. But a customer must be a User. I am a beginner and my attempt to create this relationship is confused cycle reference driving between assemblies.


1 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Use Fluent API for one-to-one relationships:

    modelBuilder.Entity<Customer>()
                .HasOne(c => c.User)
                .WithOne()
                .HasForeignKey<Customer>(c => c.UserId)
                .OnDelete(DeleteBehavior.Cascade);