From the course: .NET Essentials: LINQ for Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use the EF models in an application

Use the EF models in an application - .NET Tutorial

From the course: .NET Essentials: LINQ for Databases

Start my 1-month free trial

Use the EF models in an application

- [Instructor] At this point, we have the entity framework models graded. Let's see how to work with them in an application. For this example, I'm keeping it simple. The code is in a dotnet framework console application, in a more complex app, say a website or desktop application. We'd have to create a UI to show the output. For this example, we'll output to the console. The code is in program dot cs. We want to start by looking at the code on line 15, the entry point to everything is via the DB context class. Remember it's called Northwind Entities. So I'm instantiating the context here in line 15. And then on, once I have the context I can start working with the entity models. So let's take a look at context dot. So you see that each of the collections, categories, contact, customers, and so on is listed as a property here. And then I'm going to use that to get one record. That's what I'm doing here on line 19, I'm getting…

Contents