Nuget软件包用于微服务中的DBContext

发布于 2025-01-25 05:05:19 字数 317 浏览 1 评论 0原文

我们的团队正在使用微服务架构。它们都写在C#(和.NET 6)中。我们有一个单一的SQL Server数据库,该数据库在所有服务(共享数据库模式)上共享。

在某些服务中,我们将实体框架用作ORM与DB对话。

当我们更改数据库中的某些内容(我们使用DBUP迁移)时,我们必须手动更新消耗它们的所有微观服务中影响的实体。

为了避免,我们正在评估包装dbContext及其实体中的nuget软件包,以便可以从任何服务中消费。

我想知道这是否被认为是一种好的实践/方法,并且是否有任何缺点(除了在.NET上没有开发的服务无法消耗包装的事实)。

Our team is working with a micro service architecture. All of them are written in C# (and .NET 6). We have a single SQL Server database, shared across all the services (shared database pattern).

In some of the services we use Entity Framework as ORM to dialog with the db.

When we change something in the database (we use DbUp migrations) we have to manually update the entities affected in all the micro services that consume them.

To avoid that we are evaluating packaging the DbContext and its entities into a Nuget package so it can be consumed from any service.

I was wondering if this is considered a good practice/approach or not, and if has any drawback (besides the fact that services that are not developed on .NET won't be able to consume the package).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文