From the course: Learning Entity Framework Core

Create entities - Entity Framework Tutorial

From the course: Learning Entity Framework Core

Start my 1-month free trial

Create entities

- [Instructor] So we're ready to create our entities. So the first thing that we're going to do is to create a folder and set up a model is to create a folder and set up a model that's going to be for an actor, because our console app is simply going to list a few actors that has their name, age, a few actors that has their name, age, and whether or not they were an academy award winner. So let's go ahead and create a folder, by right-clicking on the project, selecting add, and we'll choose new folder, and we'll call it entities. Within entities, we'll add a class, called actor. And here we're going to simply name a few properties. So we'll start off with the ID. I like to use a shortcut, snippet called prop. And by typing that in and hitting tab tab And by typing that in and hitting tab tab it automatically completes it for you and now you can modify whether or not if you want an int. This is going to be an ID so I leave it as an int and then I'll simply hit enter. And now I'm ready to enter the next property. So prop again. This time it will be a string, tab, and this will be for name. Next up is age. Next up is age. That'll be an integer. And then last will be a Boolean for whether or not they were an Academy award winner. Enter, save, and that is it. Enter, save, and that is it. We have our first model. I'll build that. Save it and we are ready now to move on to our next step, which is going to be to create a DB context.

Contents