C
C#2mo ago
Foxtrek_64

Blazor - Identity Scaffolding Fails

Hi all, trying to scaffold identity into a blazor app. I have an AuthDbContext that looks like this
public sealed class AuthDbContext(DbContextOptions<AuthDbContext> options)
: IdentityDbContext<IdentityUser>(options);
public sealed class AuthDbContext(DbContextOptions<AuthDbContext> options)
: IdentityDbContext<IdentityUser>(options);
When in the scaffolding wizard, I select this db context. It works up to a point, but then I get an exception popup from Visual Studio:
---------------------------
Microsoft Visual Studio
---------------------------
Error

There was an error running the selected code generator:

'value cannot be null or empty

Parameter name: projectRelativePath'
---------------------------
OK
---------------------------
---------------------------
Microsoft Visual Studio
---------------------------
Error

There was an error running the selected code generator:

'value cannot be null or empty

Parameter name: projectRelativePath'
---------------------------
OK
---------------------------
Googling this issue doesn't find me any results for this particular error. Any ideas?
6 Replies
Foxtrek_64
Foxtrek_642mo ago
The logs do say "Empty or invalid namespace provided, using default namespace" Not sure if that matters here Ran dotnet aspnet-codegenerator identity -dc AuthDbContext and it worked. I got a new folder called Areas and it correctly scaffolded all of the items, albeit as cshtml instead of razor. I may have to manually migrate these to .razor files and put them in the Components directory, but it's a step in the right direction
Salman
Salman2mo ago
Btw what do you mean by scaffolding here ? You mean like the scaffolding wizard for a DB Model ? To make controller/pages for it ?
Salman
Salman2mo ago
Oh okay Have you made a separate Data Context for scaffolding Identity ? Btw these threads are pretty similar if you haven't tried them already : https://learn.microsoft.com/en-us/answers/questions/1182727/how-to-fix-asp-net-core-there-was-an-error-running SO : https://stackoverflow.com/questions/52022112/asp-net-core-adding-view-parameter-name-path-cannot-be-null-error
Foxtrek_64
Foxtrek_642mo ago
I have, yes Both of these say that I need a package installed, which I have already.
Salman
Salman2mo ago
Idk if it'll help or not but can you scaffold it using your default DB Context and not the new context you created ? and if you try this, make sure that your default context doesn't inherti from Identity..
Want results from more Discord servers?
Add your server