Can I use dapper-dot-net with Entity Framework?

dapper entity-framework performance

Question

I am trying to use dapper-dot-net to speed up some area of my asp.net mvc application. I am using EF5 Code first also.

Since dapper-dot-net is just some extensions for IDbConnection, can i just use

DbContext.Database.Connection 

to use dapper-dot-net? I test it is working. However, i am not sure this is the right way to use it? Especially, when I use that way, will Entity Framework still has some impact that could hurt the performance?

Popular Answer

Using Dapper could be a significant performance improvement in certain scenarios.

You can share the EF connection with Dapper. However (although unlikely to be a problem) you should be mindful of concurrency issues (e.g. due to attempts to associate multiple data readers with the same connection).

If you do run into such issues, you have the option of giving a new connection to Dapper using the connection string (DbContext.Database.Connection.ConnectionString), instead of sharing the connection.



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