In this video, learn how to seed the database, and then to how to seed the DB, and later fetch and write out the records. See how the application is run to get results.
- [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, one new Actor, and the name will be,…
- Entity Framework (EF) overview
- Uses for EF
- Installing EF
- Creating entities
- Creating the DbContext
- Performing migrations
- Creating an MVC application
- Installing EF packages
- Reverse engineering the model
- Performing context and dependency injection
- Creating the controller and the view
- Using SqlServerTypeMapper
Skill Level Intermediate
Q: This course was updated on 06/23/2017. What changed?
A: The following topics were updated: using the exercise files; Mac install prerequisites; Entity Framework on Mac, part 1; and Entity Framework on Mac, part 2.