简体   繁体   English

多租户应用程序的数据库配置

[英]Database provisioning of a multi tenant application

I am developing a multi tenant application where the provisioning process will be automated. 我正在开发一个多租户应用程序,该程序将自动执行配置过程。

The provisioning process will create a new SQL Server database with tables, procedures, functions and insert default data to the database. 设置过程将创建一个具有表,过程,函数的新SQL Server数据库,并将默认数据插入数据库。

My question is what is the best way to do this process? 我的问题是执行此过程的最佳方法是什么?

What I feel is: 我的感觉是:

1.Create multiple sets of SQL scripts like DBScripts,TableScripts,ProcScripts ect.
2.In DBScripts,just add create database code and here you can hardcode the db name also.
3.And whenver there are any changes in these scripts you can edit and release the new build for the client.

4.Client just has to click some button on front end to create DB,Tables,Sprocs etc.

After too much headache trying to execute the database script from C# I decided to restore the database programmatically using the below script. 在尝试从C#执行数据库脚本后,由于头痛不已,我决定使用以下脚本以编程方式还原数据库。

RESTORE FILELISTONLY
FROM DISK = 'C:\BaackUpFile.bak'

RESTORE DATABASE DbName
FROM DISK = 'C:\BaackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'C:\DataYourMDFFile.mdf',
MOVE 'YourLDFLogicalName' TO 'C:\DataYourLDFFile.ldf'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM