gpt4 book ai didi

azure - 带有 Entity Framework 的 Service Fabric 应用程序?

转载 作者:行者123 更新时间:2023-12-02 06:19:41 24 4
gpt4 key购买 nike

我开始学习 Service Fabric 应用程序,并且对有状态可靠服务有点困惑。

有状态的 Reliable Services 状态意味着数据将存储在我们普通数据库应用程序的表中或其他内容中?

是否可以将 EF 与有状态 Reliable Services 结合使用?

我们如何使用 Reliable Services 中的 EF 在数据库中存储/检索数据(例如产品、类别、员工等...)?

任何教程/帮助都会非常有值(value)。

提前致谢

最佳答案

可靠服务有两种类型:无状态和有状态。主要区别在于,有状态服务可以访问可靠的集合来存储您的数据。

TL;DR

如果您计划使用 Entity Framework (EF) 并且没有计划使用可靠的集合来存储数据,请坚持使用无状态服务。

第一季度

In stateful Reliable Services state means the data to be stored in the tables in our normal database applications or something else?

这意味着您计划将数据存储在 Reliable Collections 中。

第二季度

Is it possible to use EF with stateful Reliable Services ?

是的,即使您使用有状态服务,您也可以编写逻辑将数据存储在 EF 中,并且可以选择将数据存储在可靠的集合中(例如,请参阅 Oleg 在评论中提出的用例),但如果您只想使用然后 EF 寻求无状态服务。仅当您使用可靠的集合时,有状态服务才有意义。

第三季度

How we can store/retrieve the data to/from database (like Products, Categories, Employess etc...) using EF in Reliable Services?

创建无状态服务,添加 EF NuGet 包并像平常一样编写代码。

其他信息

来自this quickstart

A stateless service is a type of service that is currently the norm in cloud applications. It is considered stateless because the service itself does not contain data that needs to be stored reliably or made highly available. If an instance of a stateless service shuts down, all of its internal state is lost. In this type of service, state must be persisted to an external store, such as Azure Tables or a SQL database, for it to be made highly available and reliable.

Service Fabric introduces a new kind of service that is stateful. A stateful service can maintain state reliably within the service itself, co-located with the code that's using it. State is made highly available by Service Fabric without the need to persist state to an external store.

Reliable Collection 可以最好地描述为 No-Sql 数据存储。如果您想使用它,或者混合有状态和无状态服务,这取决于您。

有关 Reliable Collections 的更深入概述,请阅读 this doc

关于azure - 带有 Entity Framework 的 Service Fabric 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54300972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com