Back-End Development

Database-First EF Setup on VS .NET MVC Framework – Initial Folder Structure

Why Sitecore Developers Choose Perficient for jobs

Click here to read an updated post explaining the folder structure setup using GIFs.

Before you begin reading, keep in mind that this tutorial is designed for beginners. As such, it covers every step without skipping parts that might be obvious to some. This tutorial is made possible thanks to Josh Kostal, who taught me majority of what is covered in this post.

The reason you have to undergo such a tedious process to create the initial folder structure is because folders created in the File Explorer will not be mirrored inside the Visual Studio. We also have to manually reconfigure the new path to the .csproj file after moving the application over to the new folder.

Overview

  1. Create an ASP.NET Web Application (.NET Framework).
  2. Create the folder structure in the File Explorer (01 – Presentation, 02 – Application, 03 – Domain, and 04 – Database).
  3. Transfer the application created in 1) to the ’01 – Presentation’ folder.
  4. Reconfigure the path for .csproj file.
  5. Go into Visual Studio and create the Solution Folders that align with the folder structure in the File Explorer.
  6. Drag the original project into the ’01 – Presentation’ solution folder inside the Visual Studio.

Details

Creating the Folder Structure

1) Create a new ASP.NET Web Application (.NET Framework) using the MVC template. I will name the application ‘Demo_01’ in this example.

B2 P1

2) Once you create the project, go to where the project is located in the File Explorer. Inside the folder that contains the .sln file, create folders that will each hold the ‘Presentation’, ‘Application’, ‘Domain’, and ‘Database’ component.

B2 P2

3) Drag all the items in the application folder (source > repos > Demo_01 > Demo_01 in this example) into the “01 – Presentation” folder. The image below demonstrates all the items that were dragged and dropped (or copied and pasted) into the new folder.

Platforms & Technology - A Business Leaders Guide to Key Trends in Cloud
A Business Leaders Guide to Key Trends in Cloud

Cloud’s dynamic nature can make it hard to keep up with the wide-ranging capabilities that make it a key enabler to improve business processes and support a larger digital transformation.

Get the Guide

B2 P3

4) Open .sln file with a Notepad++ (Notepad works too).

B2 P4

5) Edit the path for .csproj file (now that you have moved the .csproj file from the original application folder to the “01 – Presentation” folder). You can change where it is highlighted in the image below.

B2 P5

However, when you open up the .sln file, you are going to realize how the folders you created in the File Explorer are not reflected within Visual Studio. You will have to create solution folders separately inside Visual Studio.

 

6) Right click the solution file and add a New Solution Folder (Note how it is NOT a regular New Folder).

B2 P6

7) Drag the project into the “01 – Presentation” folder and create other solution folders accordingly.

B2 P7

 

Now that we have set up the folder structure, click here to learn how you can add a SQL Server Database Project to the application here.

About the Author

David Hwang is an Associate Technical Consultant in the Sitecore/Microsoft Business Unit. He will be blogging about various concepts in technologies for beginners.

More from this Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up