Skip to content

Commit 09aae57

Browse files
committed
fixed #218: don't create duplicate user account records while seeding database
1 parent f079f9e commit 09aae57

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.EntityFrameworkCore/EntityFrameworkCore/Seed/Host/HostRoleAndUserCreator.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ private void CreateHostRoleAndUsers()
9191
_context.UserRoles.Add(new UserRole(null, adminUserForHost.Id, adminRoleForHost.Id));
9292
_context.SaveChanges();
9393

94-
// User account of admin user
95-
_context.UserAccounts.Add(new UserAccount
96-
{
97-
TenantId = null,
98-
UserId = adminUserForHost.Id,
99-
UserName = AbpUserBase.AdminUserName,
100-
EmailAddress = adminUserForHost.EmailAddress
101-
});
10294
_context.SaveChanges();
10395
}
10496
}

aspnet-core/src/AbpCompanyName.AbpProjectName.EntityFrameworkCore/EntityFrameworkCore/Seed/Tenants/TenantRoleAndUserBuilder.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,6 @@ private void CreateRolesAndUsers()
8383
// Assign Admin role to admin user
8484
_context.UserRoles.Add(new UserRole(_tenantId, adminUser.Id, adminRole.Id));
8585
_context.SaveChanges();
86-
87-
// User account of admin user
88-
if (_tenantId == 1)
89-
{
90-
_context.UserAccounts.Add(new UserAccount
91-
{
92-
TenantId = _tenantId,
93-
UserId = adminUser.Id,
94-
UserName = AbpUserBase.AdminUserName,
95-
EmailAddress = adminUser.EmailAddress
96-
});
97-
_context.SaveChanges();
98-
}
9986
}
10087
}
10188
}

0 commit comments

Comments
 (0)