Register your context with dependency injection. The concept of dependency injection is central to ASP.NET Core. Services (such as ActorDbContext) are registered with dependency injection during application startup. Components that require these services (such as your MVC controllers) are then provided these services via constructor parameters or properties.
- [Instructor] Okay, we are now ready…to register our context with dependency injection.…The concept of dependency injection…is really central to ASP.NET core,…and services like our ActorDbContext here…are registered with dependency injection…during application startup.…And components that require these services…like our MVC controllers,…they're provided these services…via constructive parameters or properties.…For more information on dependency injection…you can take a look at this site here.…
It's a Microsoft site…and have a good detailed explanation about it.…But dependency injection can become really intricate…as you get deeper into it, but on a high level,…it's really all about decoupling your code.…And it allows you to write code in a way…that your program can create objects on a fly…when it needs it.…That's really a short version of it,…but it can become much more intricate…depending on how you're using it.…But this is a good article to give you…a high level description of it.…
It's really good to completely understand it inside and out…
- 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.