miércoles, 8 de agosto de 2018

Entity Framework DbContext




Managing DbContext the right way with Entity Framework 6: an in-depth guide:  http://mehdi.me/ambient-dbcontext-in-ef6/
-          DbContextScope: a simple, correct and flexible way to manage DbContext instances



Entity Framework Working with Transactions (EF6 Onwards) : https://msdn.microsoft.com/en-gb/data/dn456843.aspx#transactionScope



Para leer:



CONCLUSIONES:

Lo que no funciona con el DbContextScope es el refresh de Ids (Identities).
Dentro de una transacción, al grabar una tabla con un campo identity, como no va contra el motor sino hasta hacer el .SaveChanges(), no tenemos información de los IDs que se deben transferir a los registros de las tablas relacionadas (hijos).
Tampoco funciona la ejecución de SP dentro de transacciones, porque el DbContextScope sólo difiere el SaveChanges() y hace uno todo junto al final, pero la ejecución de un SP no pasa por el SaveChanges().
Para transacciones lo mejor es utilizar TransactionScope().

1 comentario:

  1. I saw the need for your Social Media Viral Present and felt compelled to apply as the job description perfectly fits my abilities. Right now I am looking for a chance to create a career that I can be proud of and consequently would like to join a company (Individual Brand) like yours that can offer me an exceptional range of diverse career options.
    It seems to me now that in our not easy time there is nothing better than a casino. I really like. And playing calmly, and spinning backs and in general it's all very cool and cool. I love https://www.newcasinoslist.ca/new-casino-slots/ because this is the only normal casino. It is easy to withdraw winnings with it, it is easy to win. Everyone gets bonuses. This is cool.

    ResponderEliminar