如何在Asp.NET ZERO/Boilerplate中迁移租户数据库和主机数据库? [英] How Do I Migrate Tenant Databases and Host Database in Asp.NET ZERO / Boilerplate?

查看:125
本文介绍了如何在Asp.NET ZERO/Boilerplate中迁移租户数据库和主机数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为当前项目使用带有ASP.NET Core和Angular的ASP.NET ZERO框架.

I am using the ASP.NET ZERO framework with ASP.NET Core and Angular for my current project.

我还使用了ASP.Net ZERO的"MultiTenancy-MultiDatabase"功能.

I am also using the 'MultiTenancy - MultiDatabase' feature of ASP.Net ZERO.

在应用程序中,我在创建新的Tenant中添加了一个"Tenant1-Database"连接字符串.

In application I have added a 'Tenant1-Database' connection string in create new Tenant.

现在我有两个数据库:

  1. 主机数据库
  2. Tenant1-数据库

当我创建一个新的Tenant时,'Tenant1-Database'会根据以前的迁移文件自动更新.

When I create a new Tenant, 'Tenant1-Database' is automatically update as per previous migration files.

但是,当我使用新属性更新模型并尝试使用代码优先方法迁移数据库时,我看到主机数据库"是唯一使用新属性迁移的数据库,而Tenant1-Database没有迁移.

But when I update the model with a new property and try to migrate the database using code-first approach, I see that 'Host-Database' is the only db migrated with the new properties and Tenant1-Database is not migrated.

我的问题是:如何使用一个迁移文件迁移到两个数据库中?

My question is: How can I migrate into both databases using a single migration file?

推荐答案

是的.我找到了解决方法

在ASP.Net Zero中,整个示例模板的项目具有 Projectname.Migrator

In the ASP.Net Zero, whole sample template have project with Projectname.Migrator

ASP.Net Zero已通过控制台应用程序提供了主机数据库和所有租户数据库的迁移

ASP.Net Zero already provides the Host database and all Tenant Databases migrations by console application

只需创建一个迁移文件并使用 Projectname.Migrator

Just need to Create a migration file and execute project with Projectname.Migrator

这篇关于如何在Asp.NET ZERO/Boilerplate中迁移租户数据库和主机数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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