Key Concepts

Review core concepts you need to learn to master this subject

Database Model

using System; public class Country { public string ID { get; set; } public string ContinentID { get; set; } public string Name { get; set; } public int? Population { get; set; } public int? Area { get; set; } public DateTime? UnitedNationsDate { get; set; } public Continent Continent { get; set; } }

Entity Framework uses C# classes to define the database model. This is an in-memory representation of data stored in a database table. Several model classes combine to form the schema for the database.

Each property maps to a column in a database table. The bottom line in the example shows a type of Continent which implies a relationship to another table.

Data Projects
Lesson 1 of 5
  1. 1
    Larger ASP.NET projects often work with data stored in a database. A database is a program that allows data to be easily accessed, manipulated, and updated. The database can persist data in memory …
  2. 2
    The file RazorCountry.csproj is open. This is a project file for .NET Core. It uses markup syntax to store the . Additional frameworks added to the project will be listed here, but we’ll be us…
  3. 3
    The file Program.cs with the Main() method is the starting point for a .NET Core program. It calls the CreateHostBuilder(args) method and passes in any arguments from the command line. Method c…
  4. 4
    The file Startup.cs has a class constructor that is passed a configuration object defined by the interface IConfiguration. This interface requires the ConfigureServices() and Configure() method…
  5. 5
    The file appsettings.json stores application level settings. The application (project) can access these settings in code. Things like logging levels and database connection strings are stored h…
  6. 6
    Use the file manager to expand the Properties folder and open launchSettings.json. This file defines launch parameters with options for authentication and the web server hosting environment…
  7. 7
    Use the file manager to open the wwwroot folder. All static files are stored here. There are default folders for css (styles), js (front end JavaScript code), and lib (third party l…
  8. 8
    Our site will take advantage of the popular CSS style framework called Bootstrap. Note the version number and refer to the Bootstrap site for styling examples.
  9. 9
    The Pages folder tree contains all of the Razor Pages (.cshtml) with their associated PageModel class files (.cs). Open the Index.cshtml page to see how Razor markup is used. Notice it star…
  10. 10
    Use the file manager to open Index.cshtml.cs to see how the PageModel class is built for the page. Notice that the class name matches the Razor page name with the suffix Model. These classes mu…
  11. 11
    The file _Viewstart.cshtml is a hidden (starts with _) page that is included in all other pages. A common use for this is setting the layout page so all pages have a consistent header, left nav…
  12. 12
    _ViewImports.cshtml is a hidden page that is included at the top of each of the other pages. It is commonly used to add using statements so all code has access to the correct namespaces and ass…
  13. 13
    Use the file manager to expand the Shared folder and open _Layout.cshtml. This hidden page defines the HTML for the header, left navigation, and footer. There are two special directives use…
  14. 14
    It is easy to make changes to the default site template. This is an iterative process of code editing, saving, and running the site to see the result. Let’s make some simple changes to the **_Layou…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo