Open Closed

Add permissions to Role while seeding #3174


User avatar
0
sh_erfan created

Hi I have some predefined roles and seed them during migration. I want to add permissions to those roles during seed process. Docs recommend to define permission providers in Application.Contracts project, but PermissionDefenitionProvider are reflected while starting web project. I also moved them to Domain.Shared project, but not succeed. I will be glad if you give a good and standard solution for this scenario.


3 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I have some predefined roles and seed them during migration. Docs recommend to define permission providers in Application.Contracts project

    The .DBMigrator project reference to .Application.Contracts.

    So this is the standard solution, You can refer to PermissionDataSeedContributor to create your own Contributor: https://github.com/abpframework/abp/blob/e3e1779de6df5d26f01cdc8e99ac9cbcb3d24d3c/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeedContributor.cs#L26

  • User Avatar
    0
    sh_erfan created

    Thanks, This solved my problem What about edition features seed contributor? Do you have an example?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I'm sorry that we don't have such example.

    You can use the IFeatureDefinitionManager to get all feature definitions and use IFeatureManager to set feature.

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