ASP NET MVC Read From MSSQL (6)



In this video we learned how to define connection from ASP.NET to the SQL-DB and we were able to read data (single row) from our student table in the database and to present this information in our student-view.

في هذا الفيديو ، تعلمنا كيفية تعريف الاتصال من ASP.NET إلى SQL-DB وتمكنا من قراءة البيانات (سطر واحد) من جدول الطلاب في قاعدة البيانات وتقديم هذه المعلومات في عرض الطلاب الخاص بنا.

====
Next Video: https://youtu.be/bebezHK5FiI
Previous Video: https://youtu.be/eN1h6On57zY
====
appsettings.json:
“ConnectionStrings”: {
“DefaultConnection”: “Server=(localdb)\mssqllocaldb;Database=school;Trusted_Connection=True;MultipleActiveResultSets=true”
}

Program.cs
builder.Services.AddDbContext < MyDbContext > (options = >
options.UseSqlServer(
builder.Configuration.GetConnectionString(“DefaultConnection”)));

MyDBContext:
public MyDbContext(DbContextOptions&ltMyDbContext&gt options): base(options)
{}