以编程方式创建带有新内容数据库错误的新站点集合.对象相同的ID.SP2013

本文关键字:站点 集合 对象 SP2013 ID 新站点 创建 方式 编程 错误 数据库 | 更新日期: 2023-09-27 18:01:33

我需要在计时器作业中自动创建站点集合。当涉及到单个内容数据库时,此功能正常工作。

但是内容数据库有其局限性,需要时间来创建站点集合检查限制,如果超过规定的限制必须创建另一个内容数据库并使用它。

内容数据库的创建正在进行:

public static SPContentDatabase CriarContentDataBase(string server, string contentName, SPSite site)
{
    SPContentDatabase content = new SPContentDatabase();
    content = site.WebApplication.ContentDatabases.Add(server, contentName, null, null, 35, 40, 0);
    content.Update();
    site.WebApplication.Update();
    return content;
}

问题是创建站点集合的时间,我使用过载SPContentDataBase.Add(// parameters)方法:

SPContentDatabase currentContentDataBase = getCurrentContentDataBase(site);
using (SPSite newSite = currentContentDataBase.Sites.Add(siteCollectionURL, titulo, null, 1046, 15, TEMPLATE_NAME, loginUsuarioGestorConteudo, nomeUsuarioGestorConteudo, emailUsuarioGestorConteudo, "", "", "", currentContentDataBase.Server, currentContentDataBase.Name, null, null))
            {
                // more code
            }

这个调用返回SPException类型的异常,并带有以下消息:

The attach operation cannot continue because another object in this farm already contains the same ID. Each object in a farm must have a unique ID. In order to proceed with the attach operation you must assign a new ID to this database. To attach this database with a new ID, use the Mount-SPContentDatabase command with the -AssignNewDatabaseId parameter. Note that if this new database and an existing database contain the same site collections, attaching this database will likely result in orphaned site collections due to conflicts between the two databases.

有人能告诉我如何做,你有创建内容数据库,我修改这个ID?

谢谢。

以编程方式创建带有新内容数据库错误的新站点集合.对象相同的ID.SP2013

去中央管理>应用程序管理>管理内容数据库,看看你的Web应用程序有多少内容数据库。

如果有多个,请检查名称或id是否与您尝试创建的新名称或id相同。