使用实体框架与SQL Azure进行瞬时故障处理 [英] Transient Fault Handling with SQL Azure using Entity Framework

查看:102
本文介绍了使用实体框架与SQL Azure进行瞬时故障处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在我的应用程序中使用SQL Azure和Entity SQL。

I currently use SQL Azure and Entity SQL in my application.

例如

Entities model = new Entities();
db_Item item = model.db_Item.First();

现在我想使用企业库中的暂态故障处理,但是没有示例或解决方案我可以发现它可以做类似重写Entities类的操作,因此我不必在数百个地方更新代码。

Now I want to use the Transient Fault Handling out of the Enterprise Library but there are no examples or solutions that I can find that would allow me to do something like override the Entities class, so I don't have to update my code in hundreds of places.

有人可以请提供有关如何完成此操作的更多信息?

Could someone please provide more information on how this could be done?

推荐答案

到目前为止的内容。


  1. 实体框架不提供对打开连接和将SQL发送到服务器的部分的访问,因此当前无法在周围提供重试逻辑

  1. The Entity Framework does not provide access to the connection open and section where the SQL is sent to the server, hence it is currently impossibile to provide retry logic around this area.

EF团队已经意识到了这一不足,并计划将重试逻辑实际集成到EF中,以实现第6版。

The EF team are aware of this shortfall and are planning on actually integrating retry logic into EF for possibily version 6.

根据[1]的案例3,您可以在OnContextCreated上向数据库发送SQL命令。但是,这意味着您要对数据库进行的每个单个数据库调用都必须进行2次。除非您不关心性能,否则在几乎任何情况下都不建议这样做。

As per Case #3 of [1] you can send a SQL command to the database on the OnContextCreated. This however means for EVERY single DB call you make to the DB, you will have to make 2. I wouldn't recommend this in hardly any situation unless you don't care about performance.

到目前为止,唯一可行的选择是以每次对数据库的调用为单位,以企业库瞬态故障处理应用程序块[2]的形式实现重试逻辑。在现有的应用程序中,这非常繁琐。

The only viable option so far is implementing retry logic in the form of the Enterprise Library Transient Fault Handling Application Block [2] around every call you make to the database. In existing applications this is extremely tedious.

当我有时间的时候,我正在进一步研究EF的源代码,以查看是否可以做更多的事情,而我们等待EF6。我会密切注意[3]

When I get time I am looking further into the source code of EF to see if anything further can be done, while we wait for EF 6. I would keep an eye on [3]

有些希望,它目前正在由EF团队进行审查。 [4]

Some hope, it is currently under review by the EF team. [4]

更新: 2013-11-14

Update: 2013-11-14

我以为我会更新这篇文章,让大家知道EF6已经发布,并支持开箱即用的连接弹性。 https://www.nuget.org/packages/EntityFramework/

Just thought I would update this post to let everyone know that EF6 has been released and supports connection resiliency out of the box. https://www.nuget.org/packages/EntityFramework/

不再需要解决方法。

更新: 2013-03-23

Update: 2013-03-23

EF 6 Alpha 3随连接弹性发布- http://entityframework.codeplex.com/wikipage?title=Connection%20Resiliency%20Spec

EF 6 Alpha 3 released with Connection Resiliency - http://entityframework.codeplex.com/wikipage?title=Connection%20Resiliency%20Spec

更新: 2012-11 -04

Update: 2012-11-04

EF团队已正式宣布计划使用EF6。[4]

The EF team have officially announced it is planned for EF 6. [4]

[1 ] http://blogs.msdn.com/b/appfabriccat/archive/2010/12/11/sql-azure-and-entity-framework-connection-fault-handling.aspx

[2] http://msdn.microsoft.com/zh-CN/library/hh680934(v = pandp.50).aspx

[3] http://entityframework.codeplex。 com / wikipage?title =路线图

[4] http://data.uservoice.com/forums/72025-entity-framework-feature-建议/建议/ 2426525-自动对SQL-天蓝色执行重试逻辑

这篇关于使用实体框架与SQL Azure进行瞬时故障处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆