Menu

Asp.net core 2.0 and Entity framework Core – registering DbContext with ServiceLifetime.Transient

In your Startup.cs file you need to register the DbContext in order to use it throughout the application if you don’t register it as ServiceLifetime.Transient you will encounter threading issues as by default its ServiceLifetime.Scoped.

this is how to register it as ServiceLifetime.Transient

Hope this helps.

Leave a comment