Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 3239e73

Browse files
authored
Merge pull request #31 from episerver/user/shsh/missing-entityframework-db-schema
Add MigrateAspnetIdentity script
2 parents 69182ed + c3bf3ff commit 3239e73

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ upgrade-assistant upgrade {projectName}.csproj --extension "{extensionPath}" --i
2626

2727
### Known Issues
2828

29-
If packages.config file exists under projectpath\\module\\_protected\\ then you need to remove it before start upgrading.
29+
#### packages.config
30+
31+
If there is a packages.config file under projectpath\\module\\_protected\\ then you need to remove it before start upgrading.
32+
33+
#### Database
34+
35+
If you have used ASPNET Identity and after migration you are not able to login or get exception like "SqlException: Invalid column name 'NormalizedUserName'.", 'ConcurrencyStamp', 'LockoutEnd', 'NormalizedEmail' or missing 'AspNetRoleClaims' table, the reason is the schema between ASPNET Identity versions has been changed and the resource doesn't exist in the db. Please run the migrate MigrateAspnetIdentity.sql script file under database folder. (OBS: we recommend to take a backup of database before perform the script).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--If you are migrate from Microsoft.AspNetCore.Identity.EntityFrameworkCore 2.0 to 5.0
2+
3+
BEGIN TRANSACTION;
4+
GO
5+
6+
ALTER TABLE [dbo].[AspNetUsers] ADD [ConcurrencyStamp] nvarchar(max) NULL;
7+
GO
8+
9+
ALTER TABLE [dbo].[AspNetUsers] ADD [LockoutEnd] datetimeoffset NULL;
10+
GO
11+
12+
ALTER TABLE [dbo].[AspNetUsers] ADD [NormalizedEmail] nvarchar(256) NULL;
13+
GO
14+
15+
ALTER TABLE [dbo].[AspNetUsers] ADD [NormalizedUserName] nvarchar(256) NULL;
16+
GO
17+
18+
ALTER TABLE [dbo].[AspNetRoles] ADD [ConcurrencyStamp] nvarchar(max) NULL;
19+
GO
20+
21+
ALTER TABLE [dbo].[AspNetRoles] ADD [NormalizedName] nvarchar(256) NULL;
22+
GO
23+
24+
UPDATE [dbo].[AspNetUsers] SET [NormalizedEmail] = UPPER([Email]), [NormalizedUserName] = UPPER([UserName]) WHERE [NormalizedEmail] IS NULL
25+
GO
26+
27+
UPDATE [dbo].[AspNetRoles] SET [NormalizedName] = UPPER(Name) WHERE [NormalizedName] IS NULL
28+
GO
29+
30+
CREATE TABLE [dbo].[AspNetRoleClaims] (
31+
[Id] INT IDENTITY (1, 1) NOT NULL,
32+
[ClaimType] NVARCHAR (MAX) NULL,
33+
[ClaimValue] NVARCHAR (MAX) NULL,
34+
[RoleId] NVARCHAR (128) NOT NULL,
35+
CONSTRAINT [PK_AspNetRoleClaims]
36+
PRIMARY KEY CLUSTERED ([Id] ASC),
37+
CONSTRAINT [FK_AspNetRoleClaims_AspNetRoles_RoleId]
38+
FOREIGN KEY ([RoleId])
39+
REFERENCES [dbo].[AspNetRoles] ([Id]) ON DELETE CASCADE
40+
)
41+
GO
42+
43+
44+
COMMIT;
45+
GO

src/EpiSourceUpdater/Epi.Source.Updater.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15+
<None Remove="Database\MigrateAspnetIdentity.sql" />
1516
<None Remove="PackageMaps\EPiServerPackageMap.json" />
1617
<None Remove="PackageMaps\GetaPackageMap.json" />
1718
<None Remove="Templates\EPiServerTemplates\TemplateConfig.json" />
@@ -20,6 +21,9 @@
2021
<!-- Be sure the extension's manifest file is copied on build,
2122
so that it will be present in the extension's binary output. -->
2223
<ItemGroup>
24+
<Content Include="Database\MigrateAspnetIdentity.sql">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
</Content>
2327
<Content Include="ExtensionManifest.json">
2428
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2529
</Content>

0 commit comments

Comments
 (0)