*EDIT* Using dotnet 6.0 web project doesn't scaffold the DB

Vote:
 

Hi, 

I'm starting a new project, and come to use `dotnet-episerver create-cms-database` (v2.0.0) but it has only created 7 tables:

  • AspNetRoleClaims
  • AspNetRoles
  • AspNetUserClaims
  • AspNetUserLogins
  • AspNetUserRoles
  • AspNetUsers
  • AspNetUserTokens

and hasn't created any other tables, stored procedures, etc. Has anyone else had this situation? v1.0.0 worked fine on previous projects, but v2.0.0 seems to be problematic.

**UPDATE**

Working on this a bit further the command above is working as expected, but the .net 6.0 web project isn't scaffolding the DB, running a .net 5.0 project against the DB works fine, but not a .net 6.0 project. 

#285162
Edited, Aug 08, 2022 11:55
Vote:
 

I have tried update-database as well, but no luck.

#285163
Aug 08, 2022 12:00
Vote:
 

Output from the LOG.txt file

2022-08-08 14:37:07.104 +00:00 [INF] Running create-cms-database command.
2022-08-08 14:37:10.345 +00:00 [INF] Entity Framework Core 6.0.5 initialized 'ApplicationDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:6.0.5' with options: None
2022-08-08 14:37:10.574 +00:00 [INF] Executed DbCommand (4ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [AspNetRoles] (
    [Id] nvarchar(450) NOT NULL,
    [Name] nvarchar(256) NULL,
    [NormalizedName] nvarchar(256) NULL,
    [ConcurrencyStamp] nvarchar(max) NULL,
    CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
);
2022-08-08 14:37:10.581 +00:00 [INF] Executed DbCommand (3ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [AspNetUsers] (
    [Id] nvarchar(450) NOT NULL,
    [IsApproved] bit NOT NULL,
    [IsLockedOut] bit NOT NULL,
    [Comment] nvarchar(max) NULL,
    [CreationDate] datetime2 NOT NULL,
    [LastLoginDate] datetime2 NULL,
    [LastLockoutDate] datetime2 NULL,
    [UserName] nvarchar(256) NULL,
    [NormalizedUserName] nvarchar(256) NULL,
    [Email] nvarchar(256) NULL,
    [NormalizedEmail] nvarchar(256) NULL,
    [EmailConfirmed] bit NOT NULL,
    [PasswordHash] nvarchar(max) NULL,
    [SecurityStamp] nvarchar(max) NULL,
    [ConcurrencyStamp] nvarchar(max) NULL,
    [PhoneNumber] nvarchar(max) NULL,
    [PhoneNumberConfirmed] bit NOT NULL,
    [TwoFactorEnabled] bit NOT NULL,
    [LockoutEnd] datetimeoffset NULL,
    [LockoutEnabled] bit NOT NULL,
    [AccessFailedCount] int NOT NULL,
    CONSTRAINT [PK_AspNetUsers] PRIMARY KEY ([Id])
);
2022-08-08 14:37:10.592 +00:00 [INF] Executed DbCommand (2ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [AspNetRoleClaims] (
    [Id] int NOT NULL IDENTITY,
    [RoleId] nvarchar(450) NOT NULL,
    [ClaimType] nvarchar(max) NULL,
    [ClaimValue] nvarchar(max) NULL,
    CONSTRAINT [PK_AspNetRoleClaims] PRIMARY KEY ([Id]),
    CONSTRAINT [FK_AspNetRoleClaims_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE
);
2022-08-08 14:37:10.595 +00:00 [INF] Executed DbCommand (2ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [AspNetUserClaims] (
    [Id] int NOT NULL IDENTITY,
    [UserId] nvarchar(450) NOT NULL,
    [ClaimType] nvarchar(max) NULL,
    [ClaimValue] nvarchar(max) NULL,
    CONSTRAINT [PK_AspNetUserClaims] PRIMARY KEY ([Id]),
    CONSTRAINT [FK_AspNetUserClaims_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
2022-08-08 14:37:10.597 +00:00 [INF] Executed DbCommand (2ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [AspNetUserLogins] (
    [LoginProvider] nvarchar(128) NOT NULL,
    [ProviderKey] nvarchar(128) NOT NULL,
    [ProviderDisplayName] nvarchar(max) NULL,
    [UserId] nvarchar(450) NOT NULL,
    CONSTRAINT [PK_AspNetUserLogins] PRIMARY KEY ([LoginProvider], [ProviderKey]),
    CONSTRAINT [FK_AspNetUserLogins_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
2022-08-08 14:37:10.599 +00:00 [INF] Executed DbCommand (2ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [AspNetUserRoles] (
    [UserId] nvarchar(450) NOT NULL,
    [RoleId] nvarchar(450) NOT NULL,
    CONSTRAINT [PK_AspNetUserRoles] PRIMARY KEY ([UserId], [RoleId]),
    CONSTRAINT [FK_AspNetUserRoles_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE,
    CONSTRAINT [FK_AspNetUserRoles_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
2022-08-08 14:37:10.602 +00:00 [INF] Executed DbCommand (2ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [AspNetUserTokens] (
    [UserId] nvarchar(450) NOT NULL,
    [LoginProvider] nvarchar(128) NOT NULL,
    [Name] nvarchar(128) NOT NULL,
    [Value] nvarchar(max) NULL,
    CONSTRAINT [PK_AspNetUserTokens] PRIMARY KEY ([UserId], [LoginProvider], [Name]),
    CONSTRAINT [FK_AspNetUserTokens_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
2022-08-08 14:37:10.603 +00:00 [INF] Executed DbCommand (1ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE INDEX [IX_AspNetRoleClaims_RoleId] ON [AspNetRoleClaims] ([RoleId]);
2022-08-08 14:37:10.604 +00:00 [INF] Executed DbCommand (1ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE UNIQUE INDEX [RoleNameIndex] ON [AspNetRoles] ([NormalizedName]) WHERE [NormalizedName] IS NOT NULL;
2022-08-08 14:37:10.606 +00:00 [INF] Executed DbCommand (1ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE INDEX [IX_AspNetUserClaims_UserId] ON [AspNetUserClaims] ([UserId]);
2022-08-08 14:37:10.607 +00:00 [INF] Executed DbCommand (1ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE INDEX [IX_AspNetUserLogins_UserId] ON [AspNetUserLogins] ([UserId]);
2022-08-08 14:37:10.609 +00:00 [INF] Executed DbCommand (1ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE INDEX [IX_AspNetUserRoles_RoleId] ON [AspNetUserRoles] ([RoleId]);
2022-08-08 14:37:10.610 +00:00 [INF] Executed DbCommand (1ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE INDEX [EmailIndex] ON [AspNetUsers] ([NormalizedEmail]);
2022-08-08 14:37:10.612 +00:00 [INF] Executed DbCommand (1ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE UNIQUE INDEX [UserNameIndex] ON [AspNetUsers] ([NormalizedUserName]) WHERE [NormalizedUserName] IS NOT NULL;
2022-08-08 14:37:10.767 +00:00 [INF] create-cms-database has completed.

#285166
Aug 08, 2022 14:40
Vote:
 

The tool only creates the. database and sql logins.  It also installs asp identity core becuase if it is installed at runtime it installs as the user instead of dbo.  At runtime the rest of the schema will be installed if it does not find the schema needed to run.

#285167
Aug 08, 2022 14:53
Vote:
 

Hmmm, I must be missing something as I get this message when starting up - SqlException: Could not find stored procedure 'netSiteConfigGet'.

#285170
Aug 08, 2022 15:01
Vote:
 

Werid, it should install.  Can you check the permissions of the user in the connection string for the database is dbo

#285184
Aug 08, 2022 15:29
Vote:
 

So, I think I've gotten to the bottom of this, and it looks like when using a .net 6.0 web project it doesn't scaffold the database. Running a .net 5.0 site, the tables get added no problem.

#285231
Aug 09, 2022 8:35
Vote:
 

Okay, so I think this is related to the way .net 6.0 only uses a Program.cs by default, if I setup a new .net 6.0 project and add Optimizely it won't scaffold the tables, if I create a new .net 5.0 project (or use the CLI), upgrade it to .net 6.0 and then add Optimizely it works fine. 

#286007
Aug 23, 2022 7:08
Vote:
 

I'm not quite sure here but it should just work, I will ask the Content team to look into this

#286008
Aug 23, 2022 7:58
Vote:
 

I got response from Content team today

" they're using the new hosting model, WebApplication, without a separate startup class, https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0#webapplication. We do not support this model yet and they should see errors in the console from our initialization modules.

 "

#286062
Aug 24, 2022 11:56
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.