Search code examples
c#.netentity-frameworkazureresiliency

EntityFramework 6 Database.SqlQuery connection resiliency


I know that from version 6 EntityFramework supports connection resiliency feature when working with SQL Azure database. I am pretty sure it applies to DbSet context members.

But what if I want to execute SQL query against the database like that:

context.Database.SqlQuery<User>("select * from Users");

Is it safe to perform this operation like that? Do I need to use any Retry frameworks here? I guess no, but I want to make sure.


Solution

  • Short version: Yes.

    Long versions: The connection resilience is applied on the IDbConnection level. That direct sql query only generates a new IDbCommand that will be delivered to the sever by the same IDbConnection as all the others.