2012-08-09 68 views
0

我正在开发一个多租户应用程序,供应过程将自动完成。多租户应用程序的数据库配置

供应过程将创建一个包含表,过程和函数的新SQL Server数据库并向数据库中插入默认数据。

我的问题是做这个过程的最好方法是什么?

+0

您是否想为新客户即时创建新数据库?并想知道哪个是最好的方法? – 2012-08-09 07:14:26

+0

是的,这是正确的 – 2012-08-09 07:16:33

+0

会“通过运行初始化TSQL脚本作为管理员帐户,代替db-name”太明显答案? – 2012-08-09 07:17:17

回答

0

后太多头痛试图执行从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' 
0

我的感觉是:

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.