- Home
- .NET code examples
- Get started with Entity Framework Core
Get started with Entity Framework Core
Download the code example for our Get Started with EF Core course.
The course begins with creating a DbContext into an ASP.NET Core Web API. The DbContext allows the Web API to communicate with the SQL Server database.
C# coding challenges
So we can support continuous integration and deployment, we then focus on how to add migrations and update the database.
The next stages focus on CRUD operations. The code features the ability to create, read, update or delete an entity from a database using the Web API.
Joining data is one of the fundamental skills you need to know. The code features examples on how to use the Include
method to join two tables together.
Finally, we round it off with using Entity Framework to query using raw SQL queries and stored procedures.
Software
This is the software that will need to be installed onto your machine.
- Visual Studio 2022. Version 17.8.3 or above. It will work with the free community version.
- .NET 8 SDK. version 8.0.1 or above.
- SQL Server Management Studio.
Install LocalDB
Make sure that you have LocalDB installed on your machine. You can check in Visual Studio by going to Tools and Get Tools and Features....
This will load up the Visual Studio Installer. If you go to the Individual components tab and do a search for LocalDB.
If SQL Server Express LocalDB is ticked, it is already installed. If it's not, just enable it and follow the instructions to install it.
Get the application working
Download the code example
Fill out the code example form. We will send you an email where you can download the code example.
Importing the database
The database can be found in the Database
folder as part of the code example.
In SQL Server Management Studio, connect to LocalDB by selecting the Server name as (localdb)\MSSQLLocalDB
and the Authentication as Windows Authentication.
Right-click on the Databases folder and go to Import Data-tier Application.
In the Import Settings tab, select Import from local disk and find RoundTheCodeEFCore.bacpac
which is included in the Database
folder of the code example.
In the Database settings tab, ensure that the New database name is set as RoundTheCodeEFCore
.
You should be able to continue through the next steps with the options untouched and it should successfully import the database.
Open the project in Visual Studio
Open up RoundTheCode.EFCore.sln
in Visual Studio 2022.
Start the project in Visual Studio. It will load up https://localhost:7110/swagger/index.html
.
You can test out each of the endpoints and see what response is returned.
More information
You are downloading the code example for the whole of the course.
Remember to check out each of the six-parts in our Get Started with EF Core course to understand how the code example works.