Learn about the DbContext and also in order to use EF, you need to create a class that derives from the DbContext base class. Each DbContext class you write will give you access to a specific DB. Learn how the connection string can be modified to point to different databases that can be used, and the DbContext maps to a specific DB that has a schema the DbContext understands.
- [Instructor] To use Entity Framework,…we need to create a class…that derives from DbContext base class.…Each DbContext class that we write,…will give us access to a specific database.…The connection string can always be modified…to point to different databases that can be used.…The DbContext maps to a specific database that has a schema,…that the DbContext understands.…On that DbContext, you can create properties…that are type of DbSet, of T.…The generic type paramater T, will be an entity,…like Actor is an entity in this demo console application.…
So if I want an Actor database,…I'll simply create an Actor DbContext class,…and implement a DbSet of Actor, on that class.…In the Actor DbContext, DbSets,…will map to tables in the database, like a table of actors.…The mapping can become quite complex,…but we won't be doing anything sophisticated at this point.…So let's go ahead and see this in action.…In our application, I need a class…that derives from DbContext,…so I'm going to go ahead and put it in our Entities folder,…
- 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.