简体   繁体   English

多租户应用程序-自动创建数据库

[英]Multi Tenant Application - Auto Create Database

I have a multi tenant application which I am trying to deploy on Azure using a web app package. 我有一个多租户应用程序,正在尝试使用Web应用程序包在Azure上进行部署。

When a user registers for a new account at that moment a database is created for them and this works flawlessly on my development machine with SQL Server 2014. 当用户此时注册一个新帐户时,将为他们创建一个数据库,并且该数据库在我使用SQL Server 2014的开发计算机上可以正常工作。

Do I need to configure the database server on Azure to allow this, if so how? 我是否需要在Azure上配置数据库服务器以允许此操作(如果允许)?

Not creating the database may be caused by a timeout. 未创建数据库可能是由于超时引起的。 See this post: Entity Framework Database Initialization: Timeout when initializing new Azure SqlDatabase 请参见此文章: 实体框架数据库初始化:初始化新的Azure SqlDatabase时超时

If you need a new database to be created when someone signs up, you can better create the database before firing up Entity Framework. 如果在有人注册时需要创建新的数据库,则最好在启动Entity Framework之前创建数据库。

This can be done using either T-SQL (1) when connected to the master database of your server or using the Azure Sql Managment Libraries (2). 连接到服务器的主数据库时,可以使用T-SQL(1)或使用Azure Sql管理库(2)来完成。 I would recommend option two since it will allow you to depend on a nice abstraction rather than interacting with the database directly. 我建议使用选项二,因为它可以让您依赖一个不错的抽象,而不是直接与数据库进行交互。

1: https://msdn.microsoft.com/en-us/library/dn268335.aspx 1: https//msdn.microsoft.com/zh-CN/library/dn268335.aspx

2: https://www.nuget.org/packages/Microsoft.Azure.Management.Sql 2: https//www.nuget.org/packages/Microsoft.Azure.Management.Sql

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

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