Base solution for your next web application
Open Closed

Seed method creates duplicate records in AbpFeatures table #1634


User avatar
0
rickwheeler created

The seed method is creating duplicate records in AbpFeatures table. The issue is even worse if update-database has been run more than once

Issue:

Id	Name	Value	CreationTime	CreatorUserId	EditionId	TenantId	Discriminator
1	App.ChatFeature	True	2016-09-05 15:27:34.967	NULL	1	NULL	EditionFeatureSetting
2	App.ChatFeature	True	2016-09-05 15:27:34.967	NULL	1	NULL	EditionFeatureSetting
3	App.ChatFeature	True	2016-09-05 15:27:34.970	NULL	1	NULL	EditionFeatureSetting
4	App.ChatFeature	True	2016-09-05 15:27:34.970	NULL	1	NULL	EditionFeatureSetting
5	App.ChatFeature	True	2016-09-05 15:35:37.130	NULL	1	NULL	EditionFeatureSetting
6	App.ChatFeature	True	2016-09-05 15:35:37.130	NULL	1	NULL	EditionFeatureSetting
7	App.ChatFeature	True	2016-09-05 15:35:46.173	NULL	1	NULL	EditionFeatureSetting
8	App.ChatFeature	True	2016-09-05 15:35:46.173	NULL	1	NULL	EditionFeatureSetting

Fix: In ABPZero.EntityFramework/Migrations/Seed/Host/DefaultEditionCreator.cs

Replace

_context.EditionFeatureSettings.Add(new EditionFeatureSetting
     {
         Name = AppFeatures.ChatFeature,

With

_context.EditionFeatureSettings.Add(new EditionFeatureSetting
     {
         Name = featureName,

2 Answer(s)
  • User Avatar
    0
    rickwheeler created

    You may also like to add a unique index to the table on Name + EditionId + TenantId

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thanks for your report, we have fixed it. I will check for your Index suggestion as well.