Skip to main content

Category: Entity Framework Core

EF Core – Unable to create an object of type DbContext

This problem has bitten me more than once, and I can never remember how to fix it. So, why not write a blog post about it! When running EF Core migrations in a solution, you may come across this error: There are several apparent causes. However, in my case (every time I have seen this), it has been caused by having multiple startup projects selected in Visual Studio. To fix this, simply open your Solution properties and set the startup project to ‘Current Selection’.