Reputation: 13621
I would like to access an entity (called Document) which is mapped to a table (called Document) using Entity Framework 1.0 but it is very important that this table is not locked when the data is read.
There are articles both online, and on stackoverflow that suggest using transaction scope for this. But I don't initially feel comfortable creating a transaction for a read.
Therefore my question is:
Upvotes: 3
Views: 455
Reputation: 364319
You can't force EF to use NOLOCK hint until you write your custom entity framework provider where you will control creation of all SQL statements. If you want to try it check these provider wrappers which can be used to wrap existing EF providers. But still it would require parsing and modifying already created SQL statements which can be quite complex task with big impact on performance.
As I understand it, each statement runs in its own transaction. That is the reason why locking causes issues. Wrapping statements in TransactionScope
with lower isolation level just reconfigures implicit transaction. But be aware that uncommited reads are also called dirty reads - you can get uncommited data.
Upvotes: 2