ASP.NET Core web project architecture (step by step guide) - Part 1 - Separation of the database entities

 Creating a decent project architecture when starting a new project is a must, when talking about serious web applications. The architecture is not something that just happens during the implementation of the project, but should be considered since the creation of the project. The other aproach is also possible, but in my opinion is not advisable.
 Our templates provides you similar (to what you will see) project architecture, but this article is intended to familiarize you with the details and steps of their implementation.

1. Create the new type of web application ASP.NET Core web application

  I will call the project - ArchitectureExample
...

 Then you would be prompt with another window in which you should select - Web Application (Model-View-Controller) and change the authentication to Individual User Accounts.
...

 So far there isn't something special. You should now have the default MVC project architecture, which looks like that.
...
 But unfortunately it has a lot of drawbacks. For example:
  • Coupling of the web application and the database
  • Coupling of the web application and the business logic
  • Coupling in general of everything which could be put in a separate and independent project

2.Create real and solution folder called Data

Visual Studio has a structural entity called solution folder, which shows a folder in the solution explorer, but it doesn't really create physical folder on the disk.
This is why you should create it manyally from the file explorer
...
as well as a solution folder. Then you create new project which should be called {Name of the Project}.Data or ArchitectureExample.Data in our case and place it inside that new Data folder located in the main solution folder.
...

Finally you should end up with this:
...

3.Move the data content

 When you have the new project created you can now move the content of the Data folder from the web application to the new ArchitectureExample.Data project. Simple cut and paste will do the job.
...
  At this point the project would not be able to build, because we don't have reference between the projects, and we haven't installed the neccessary NuGet packages in our new project as well. So it's normat to have an errors like that.
...

4.Add reference to the new project

  The first step we can do is to make a reference between our Class Library and the Web Project. If you have fallowed the naming conventions which I set up, this should fix some of the errors, but of cource not all of them.
...

5. Install Entity Framework package

 The current implementation of the database expect that you should have Entity Framework package installed, which currently we don't have in our Class Library project. So lets install it. This package installs a lot of different related packages, but this is normal.
...

  Another package which should be installed is the EntityFramework SqlServer.
...

 As a conclusion I would say that this is the first step of the creation of our extended architecture. We are far from ready and there is a lot to come in the next parts.
In the part 2 we will discuss how create the Separation between the Web project, Business logic, Tests and Tools.