Within the same transaction, using Dapper and Entity Framework

.net dapper entity-framework sql-server

Question

Are there any problems or pitfalls when combining Entity Framework 6 with Dapper with SQL Server?

1
1
4/10/2017 5:41:45 PM

Popular Answer

using (var db = new MyDbContext())
using (var tran = db.Database.BeginTransaction()){

    //EF
    var hoge = db.HogeTable.FirstOrDefault();
    hoge.Name = "fuga";
    db.SaveChanges();

    //Dapper
    // create query and params
    db.Database.Connection.Execute(query, params, tran.UnderlyingTransaction);
    tran.Commit();
}
0
2/19/2018 8:05:32 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow