Posts

Showing posts with the label Entity Framework Core

Database First Approach in Entity Framework Core: A Step-by-Step Guide

Image
Introduction: In this blog, I'll walk you through the process of setting up an Entity Framework Core project with a focus on Microsoft SQL Server as the database provider. Setting Up the Database: To begin, we created two tables, namely "Students" and "Teachers," in the "SampleDB" database. This forms the foundation for our data model. Creating the MVC Project: Next, we initiated a new MVC project using Visual Studio. Installing Necessary Packages: In the Package Manager Console, execute the following commands to install the essential packages for Entity Framework Core: Install-Package Microsoft.EntityFrameworkCore.SqlServer Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design Install-Package Microsoft.EntityFrameworkCore.Tools Microsoft.EntityFrameworkCore.SqlServer: Installs the required package to enable Entity Framework Core with Microsoft SQL Server as th...

Entity Framework Core (EF) with SQL Server LocalDB

Image
This blog is going to illustrate how to implement Entity Framework (EF) Core with SQL Server LocalDB. The Entity Framework Core enables access to data from the database. This allows developers to avoid having to write most of the data access code. And the SQL Server LocalDB works similarly to the SQL SERVER with few features. You can get the LocalDB when you install visual studio or visual studio express. You can find the .mdf and _log.ldf files in the C:/Users/{user} directory. Let see how to create a SQL Server LocalDB and implement Entity Framework Core Step 1: The first step is to add a connection. In the menu -> click Tools and select Connect to Database It will display the Add Connection window. Enter (localdb)\mssqllocaldb in the server name textbox. Then in the Select or enter a database, select master and click ok Now in the server explorer, you can find the master DB containing Tables, Views, Stored...