Last active
August 26, 2019 03:19
-
-
Save arichika/32b529e6f50779a03979f0ff9d09b436 to your computer and use it in GitHub Desktop.
Blog:OneWorldDbClient:201908261200:Startup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Startup.cs | |
services.AddScoped(_ => | |
new OneWorldDbClientManager<YourEfDbContext>( | |
Configuration.GetConnectionString("DefaultConnection"), | |
(connection, transaction) => | |
{ | |
var dbContext = new YourEfDbContext( | |
new DbContextOptionsBuilder<YourEfDbContext>() | |
.UseSqlServer((DbConnection)connection) | |
.Options); | |
dbContext.Database.UseTransaction((SqlTransaction)transaction); | |
return dbContext; | |
}, | |
connStr => new SqlConnection(connStr), | |
_.GetRequiredService<ILogger<OneWorldDbClientManager<YourEfDbContext>>>(), | |
_.GetRequiredService<ILogger<OneWorldDbTransaction<YourEfDbContext>>>())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment