Andrei
Andrei

Reputation: 44600

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.

Upvotes: 0

Views: 428

Answers (1)

Jo&#227;o Silva
Jo&#227;o Silva

Reputation: 569

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.

Upvotes: 1

Related Questions