从VS C#创建Azure SQL数据库时设置服务层 [英] Set Service Tiers when create Azure SQL database from VS C#

查看:103
本文介绍了从VS C#创建Azure SQL数据库时设置服务层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中从Visual Studio创建新数据库时,是否可以设置Microsoft Azure SQL数据库服务层?当前,我可以毫无问题地连接到Azure SQL服务器并创建表,但是由于某种原因(也许是Microsoft Default),数据库将在Web中创建,这是将要淘汰的服务层.我想根据需要将默认服务层设置为基本",标准"或高级".

Is it possible to set the Microsoft Azure SQL Database service tiers when creating a new database from Visual Studio in C#? Currently, I can connect to the Azure SQL server and create table with no problem but for some reason (maybe Microsoft Default) the databases will be created in Web which is the service tier that going to be retired. I would like to set the default service tiers to either be Basic, Standard, or Premium depends on the needs.

到目前为止,我找到的是调用此方法Database.Initialize(true)<-EF http://msdn.microsoft.com/zh-CN/library/system.data.entity.database.initialize(v=vs.113).aspx 它将创建数据库并将其设置为Web服务层.

What I found so far is when I call this method Database.Initialize(true) <--EF http://msdn.microsoft.com/en-us/library/system.data.entity.database.initialize(v=vs.113).aspx It would create the database and set it to Web service tier.

推荐答案

使用Azure SQL v12,您可以选择指定SKU. 示例:

With Azure SQL v12 you have the option to specify the SKU. Example:

var dbCreationCmd = $"CREATE DATABASE [{databaseName}] (MAXSIZE={maxSize}," +
                            $"EDITION='{edition}'," +
                            $"SERVICE_OBJECTIVE='{serviceObjective}')";

// With Azure SQL db V12, database creation TSQL became a sync process. 
// So we need a 10 minutes command timeout
ExecuteNonQuery(connectionString, dbCreationCmd, commandTimeout: 600);

这篇关于从VS C#创建Azure SQL数据库时设置服务层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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