Open Closed

Default values for extension properties of user on tenant creation #921


User avatar
0
ya-dev created
  • ABP Framework version: v4.0

Hi,

I've added extension column to users table which is a foreign key to another table. While creating a new tenant, framework tries to create an admin user for that tenant but it fails because of this extension column which is null while creating the admin user. How can I resolve this issue?

Thanks for your help.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

4 Answer(s)
  • User Avatar
    0
    ilkayilknur created

    See https://docs.abp.io/en/abp/latest/Module-Entity-Extensions#default-value

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ya-dev created

    That's not working while creating a tenant. Have you ever tested it? Can you provide a working example for IdentityUser entity?

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ilkayilknur created

    You can also specify default value for the extension property in {ProjectName}EfCoreEntityExtensionMappings.cs inside {ProjectName}.EntityFrameworkCore project like this.

    ObjectExtensionManager.Instance
        .MapEfCoreProperty<IdentityUser, string>(
            "SocialSecurityNumber",
            (entityBuilder, propertyBuilder) =>
            {
                propertyBuilder.HasDefaultValue("test");
            }
        );
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ya-dev created

    It seems to be working. I've missed it because of an intellisense issue. Thanks for your help.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.