From the course: Learning Entity Framework Core

Unlock the full course today

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

Seed and run app

Seed and run app - Entity Framework Tutorial

From the course: Learning Entity Framework Core

Start my 1-month free trial

Seed and run app

- [Instructor] The last two things we want to do with our app is to seed it with a couple of more records and write the code to send it to the console when executing it. So let's navigate to the main method in the program file and get started. The first thing we'll want to do is to create a using clause and instantiate our active DB context. So I'll start off with "using," and simply set a variable called a DB, and we'll call ActorDBContext. Hold the Control key down, and hit period, so I can import the name space, and a quick shortcut that I also would like to show you, let me get rid of this, I really like using a snippet, so sometimes instead of, like we're writing out the using statement just by hand completely, I could just hit tab, tab, and it automatically just sets it up for you, the resource. So using db equals new ActorDBContext, and within here, we can start with our seeding process to add a couple of records. So let's say that this is db.Actors, and we'll invoke AddRange…

Contents