Visual Studio 数据库项目和 SQL Azure

发布于 2024-10-25 13:16:37 字数 1017 浏览 0 评论 0原文

我真的在努力寻找管理基于 Visual Studio 2010 数据库项目的 SQL Azure 数据库的最佳方法。我认为使用 VSDBCMD 创建用于升级的 diff 脚本非常容易,然后只需在 SSMS 中针对 SQL Azure 运行即可。但是,我收到了可怕的“无法确定目标数据库架构提供程序。部署无法继续。”错误。

此时,我只是假设 SQL Azure 不支持 VSDBCMD 中的某些内容,反之亦然,并且我正在寻找其他方法。以下是我目前正在考虑的方法:

  1. 使用 Azure 数据库引擎设置从 SSMS 编写 SQL Azure 数据库脚本。
  2. 根据步骤 1 中的脚本创建临时本地数据库。
  3. 使用 VSDBCMD 针对步骤 2 中的本地数据库创建增量脚本。
  4. 查看/修改步骤 3 中的脚本
  5. 。针对 SSMS 中的 SQL Azure 运行步骤 3/4 中的脚本。

好、坏?还有其他想法吗?

编辑:我今天更新到 Visual Studio 2010 SP1,发现 Microsoft.Data.Schema.Sql.dll 中有一个新的数据库架构提供程序:SqlAzureDatabaseSchemaProvider。但是,我无法确定如何实际使用这个坏男孩。现在,当我针对 Azure 数据库尝试相同的 VSDBCMD 脚本时,我得到:

源数据库架构提供程序 Sql100DatabaseSchemaProvider 无法转换为提供程序 SqlAzureDatabaseSchemaProvider。部署无法继续。

我还尝试使用 Sql90 提供程序获得相同的结果。我什至手动编辑了 dbproj 文件并将 DSP 属性更改为 SqlAzureDatabaseSchemaProvider。当我重新加载项目时,我得到:

数据库架构提供程序必须提供 DataGenerationServices 的实现。

有人用 VS 2010 SP1 尝试过吗?

I'm really struggling with the best approach for managing a SQL Azure database which is based on a Visual Studio 2010 Database Project. I figured it would be easy enough to use VSDBCMD to create diff scripts for upgrades and then simply run against SQL Azure in SSMS. However, I get the dreaded "The target database schema provider could not be determined. Deployment cannot continue." error.

At this point I'm just assuming either SQL Azure doesn't support something in VSDBCMD or vice versa and I'm looking at other approaches. Here's the approach I'm currently considering:

  1. Script my SQL Azure database from SSMS using the Azure database engine setting.
  2. Create a tempory local database from script in step 1.
  3. Use VSDBCMD to create my delta script against the local database from step 2.
  4. Review/modify the script from step 3.
  5. Run script from step 3/4 against SQL Azure in SSMS.

Good, bad? Any other ideas?

EDIT: I updated to Visual Studio 2010 SP1 today and found that there is a new database schema provider in Microsoft.Data.Schema.Sql.dll: SqlAzureDatabaseSchemaProvider. However, I cannot determine how to actually use this bad boy. Now when I try the same VSDBCMD script against an Azure database, I get:

The source database schema provider Sql100DatabaseSchemaProvider could not be translated to provider SqlAzureDatabaseSchemaProvider. Deployment cannot continue.

I also tried using the Sql90 provider with the same outcome. I even manually edited the dbproj file and changed the DSP property to SqlAzureDatabaseSchemaProvider. When I reload the project I get:

The database schema provider must provide an implementation of DataGenerationServices.

Has anyone tried this with VS 2010 SP1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

随风而去 2024-11-01 13:16:37

您可以使用SQL Azure 迁移向导并使用它。也许您可以获取脚本并根据需要进行编辑。只是一个想法。

You can use the SQL Azure Migration Wizard and play with it. Maybe you can get the scripts and edit them as you want. Just an idea.

墨离汐 2024-11-01 13:16:37

查看数据库项目的属性页。它应该显示一个包含该项目的各种可用提供商的下拉列表。如果选择 Azure 提供商,您应该能够将该项目部署为 Azure 应用程序的一部分。

Check out the properties page of the database project. It should show a dropdown containing the various available providers for the project. If you select the Azure provider you should be able to deploy the project as part of your Azure application.

生来就爱笑 2024-11-01 13:16:37

只需一个简单的命令行工具即可替换无效的 SQL Azure 语句:

    private const string STARTPLACEHOLDER = "AZURESCRIPTSTARTPLACEHOLDER";

    public static void Do(string fileName)
    {
        // Read the original file
        StringBuilder script = new StringBuilder();
        using (StreamReader reader = new StreamReader(fileName))
        {
            script.Append(reader.ReadToEnd());
        }

        // Remove everything before the start placeholder
        int startPlaceHolder = script.ToString().IndexOf(STARTPLACEHOLDER, 0);
        if (startPlaceHolder > 0)
        {
            script.Remove(0, startPlaceHolder + STARTPLACEHOLDER.Length);
        }

        // Remove WITH clause
        script.Replace("WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF)", string.Empty);

        // Create azure compatible output file
        using (StreamWriter writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + "_Azure" + Path.GetExtension(fileName))))
        {
            writer.Write(script.ToString());
        }
    }

A simple command line tool that replaces invalid SQL Azure statements is all that is needed:

    private const string STARTPLACEHOLDER = "AZURESCRIPTSTARTPLACEHOLDER";

    public static void Do(string fileName)
    {
        // Read the original file
        StringBuilder script = new StringBuilder();
        using (StreamReader reader = new StreamReader(fileName))
        {
            script.Append(reader.ReadToEnd());
        }

        // Remove everything before the start placeholder
        int startPlaceHolder = script.ToString().IndexOf(STARTPLACEHOLDER, 0);
        if (startPlaceHolder > 0)
        {
            script.Remove(0, startPlaceHolder + STARTPLACEHOLDER.Length);
        }

        // Remove WITH clause
        script.Replace("WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF)", string.Empty);

        // Create azure compatible output file
        using (StreamWriter writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + "_Azure" + Path.GetExtension(fileName))))
        {
            writer.Write(script.ToString());
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文