Open Closed

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


User avatar
0
yilmaz.atalar 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.


4 Answer(s)
  • User Avatar
    0
    ilkayilknur created

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

  • User Avatar
    0
    yilmaz.atalar created

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

    Thanks.

  • 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");
            }
        );
    
  • User Avatar
    0
    yilmaz.atalar created

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

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11