You are on page 1of 27

Web Programming

Xhelal Jashari
xhelal.jashari@ubt-uni.net
Web Programming

Understanding of Model
ASP.NET Core Web Application Web Programming

 Solution Explorer
 Solution name
 Project
 Other files under project
 Models
Understanding of Model Web Programming
Understanding of Model Web Programming

• A model is a class that contains the business logic of the


application.

• It also used for accessing data from the database.

• The model class does not handle directly input from the
browser.

• It does not contain any HTML code as well.


Understanding of Model Web Programming

• Models are also refers as objects that are used to implement


conceptual logic for the application.

• A controller interacts with the model, access the data, perform the
logic and pass that data to the view.

• Model contains setter and getter for its properties.


Understanding of Model Web Programming

• Creating a Model
To add the model, just right click on
the Model folder of the project and
then follow this:
Understanding of Model Web Programming

• Creating a Model: Class > Student


Understanding of Model Web Programming

DbContext
• Application DbContext

• Connection String> Default Connection


ConfigureServices
Understanding of Model Web Programming

• Application DbContext and DbSet


Understanding of Model Web Programming

• Connection String> Default Connection


Understanding of Model Web Programming

• ConfigureServices
Understanding of Model Web Programming

• ConfigureServices
Understanding of Model Web Programming

• Create the database


Understanding of Model Web Programming

• Scaffold the student model

The scaffolding tool produces pages for


Create, Read, Update, and Delete
(CRUD) operations for the student
model.
Understanding of Model Web Programming

• Migrations and Students Views


Understanding of Model Web Programming

• Student Create
Understanding of Model Web Programming

• Student Delete
Understanding of Model Web Programming

• Student Details
Understanding of Model Web Programming

• Student Edit
Understanding of Model Web Programming

• Student Index
Web Programming
NuGet Package Manager Web Programming

• NuGet
Package Manager
NuGet Package Manager Web Programming

Enable runtime compilation at project creation


The Razor Pages and MVC project templates include an option to enable runtime compilation
when the project is created.

This option is supported in ASP.NET Core 3.1 and later.

Source: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-6.0&tabs=visual-studio
NuGet Package Manager Web Programming

Enable runtime compilation in an existing project


To enable runtime compilation for all environments in an existing project:

Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.

Update the project's Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation.

For example:
NuGet Package Manager Web Programming

Entity Framework Core Tools


Enables these commonly used commands:

• Add-Migration
• Drop-Database
• Get-DbContext
• Scaffold-DbContext
• Script-Migrations
• Update-Database
ConnectionStrings Web Programming

ConnectionString Examples

You might also like