The NuGet package https://www.nuget.org/packages/Terralect.ChannelExpress.SqlDbContextScope/ is a Channel Express filter that manages your Entity Framework DbContext on your behalf.
This package is actually leveraging off of the Terralect.ChannelExpress.SqlScope package, which is also a Channel Express filter package. The SqlScope filter automatically creates a SqlConnection and SqlTransaction, which can be accessed by injecting ISqlConnectionScope in a Channel Express filter, handler or scoped class in the Channel.
Once the SqlDbContextScope package is configured, you will inject in an IDbContextScope to gain access your DbSets.
You will not be required to call the DbContext SaveChanges() method, as this is handled automatically in the Channel Express filter.
The minimum required setup will look as follows:
dbContextConfig.ConnectionString = "your_connection_string";
dbContextConfig.SetDbContextProvider(options => new LocalDbContext(options));
Also, your DbContext class should have the following constructor:
public LocalDbContext(DbContextOptions<LocalDbContext> options) : base(options)
Once you have injected IDbContextScope, you will have access to the following methods:
* This allows you to access a DbSet directly.
* This accesses a DbSet, disables the EF tracking and returns an IQueryable.
* This gives you direct access to the instance of your DbContext that was created.