They are two different things. AddDbContext adds your DbContext to the service collection. CreateScope creates a new scope in the IoC container. By default, a DbContext gets added as a scoped service lifetime in dependency injection, so you have to create a custom scope if you want to resolve your DbContext outside of a HTTP request. This is what we are doing to check the connection of the database because the application isn't running at this point. Check out my LinkedIn course on dependency injection to learn more about it. www.roundthecode.com/dotnet-courses