CREATE FULLTEXT INDEX/CATALOG 语句不能在用户事务中使用

CREATE FULLTEXT INDEX/CATALOG statement cannot be used inside a user transaction

我有一个数据库版本控制应用程序来更新已部署的数据库。它 运行 几乎所有 SQL 语句都很顺利,但是当我决定使用全文搜索并生成脚本来使用像下面这样的语句时,它就崩溃了。

CREATE FULLTEXT CATALOG [ProductCatalog]

--Create fulltext index on Product
CREATE FULLTEXT INDEX ON [tblProduct] KEY INDEX [PK_Catalog]
    ON ([ProductCatalog]) WITH (CHANGE_TRACKING AUTO)
ALTER FULLTEXT INDEX ON [tblProduct] ADD ([ProductName] LANGUAGE [English])
ALTER FULLTEXT INDEX ON [tblProduct] ENABLE

我使用以下代码在 C# SqlTransaction

中执行 SQL 文件
SqlConnection cnn = new SqlConnection("cstring");
SqlTransaction trn = cnn.BeginTransaction();

cnn.Open();

using (SqlCommand cmd = cnn.CreateCommand())
{
    cmd.Connection = cnn;       
    cmd.Transaction = trn;

    cmd.CommandText = SQLScript;
    cmd.CommandType = CommandType.Text;
    cmd.ExecuteNonQuery();
}

trn.Commit();        
cnn.Close();

如何在没有交易的情况下运行我的脚本?

我修改了代码以执行脚本

SqlConnection cnn = new SqlConnection("cstring");
SqlTransaction trn = null;

cnn.Open();

using (SqlCommand cmd = cnn.CreateCommand())
{
    cmd.Connection = cnn;

    if(!SQLScript.Contains("FULLTEXT"))
    {
        trn = cnn.BeginTransaction();
        cmd.Transaction = trn;
    }        

    cmd.CommandText = SQLScript;
    cmd.CommandType = CommandType.Text;
    cmd.ExecuteNonQuery();
}

if(trn!=null)
    trn.Commit();

cnn.Close();