Authentication - Context and Layout Location Best Practices / Targeting Context

Dean Everhart 1,541 Reputation points
2023-04-14T14:45:37.2266667+00:00

Two Questions:

1. I want to resolve the error below

2. I mirrored the Views.Shared._Layout.cshtml and Data....Context.cs hierarchy within the Areas.Identity folder (see: Solution Explorer below) ...the thought being to keep Authentication concerns separate from the project. This maynot (probably is not) the best way to go about this; should I / how should I organize this differently?

Question: What is the best practice for location of the layout and context items for a project?

GitHub: Authentication Tutorial: Introduction to Identity on ASP.NET Core / Migrations My Notes: Authentication Environment: Net Core 6, Visual Studio Community 2022 (64 bit), WIndows 11

Error: User's image

Solution Explorer: User's image

Thank you.  

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-04-14T15:11:19.75+00:00

    With c# code, the folder structure does not matter. Only the namespace and object names. While it’s common for the namespace to match the folder structure, it’s not a requirement. Most likely your dbcontext namespace does not match. As for the best place, for a dbcontext, would be its own project.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.