Загрузка...

Bind List box from Database using entity framework in ASP NET Core Razor Pages | Part 19

Bind List box from Database using entity framework in ASP.NET Core Razor Pages using Visual studio 2022
Requirement: SQL server 2012, Visual studio 2022

Implementation Design:

SQL table:
CREATE TABLE [hobbies_master](
[id] [int] IDENTITY(200,1) NOT NULL,
[hobby_name] [nvarchar](255) NOT NULL,
[display_order] [int] NULL,
PRIMARY KEY CLUSTERED
([id] ASC))

Steps:1
Installation Required through NuGet packages
1) Microsoft.EntityFrameworkCore.SqlServer
2) microsoft.entityframeworkcore.tools
3) Microsoft.Extensions.Configuration


Steps:2
Create a folder Models then Create a Class through the command line of Nuget Package:
Scaffold-DbContext "Server=DESKTOP-HSSNFCU;Database=Sample_db;Trusted_Connection=True; TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
-force
Steps:3
// add db context to the container
builder.Services.AddDbContext use less sign SampleDbContext use greater sign ();
Step 4:
public class HobbyMasterViewModel
{
define property

}
.cshtml page
.cshtml.cs page

Видео Bind List box from Database using entity framework in ASP NET Core Razor Pages | Part 19 канала Syed Ali
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять