如何在SyncFramework中将数据库架构更改为.dbo

时间:2016-09-05 18:55:21

标签: microsoft-sync-framework

在serverProvision.Apply tablename_tracking表之后的同步SyncFramework和使用服务器连接字符串创建的存储过程DB UID for ex:tasnim_DBUser.tabelname_tracking或tasnim_DBUser.tablename_selectchanges,...

server connectionstring : @"Data Source=sitedomain,1433;Persist Security Info=false;Initial Catalog=databasename;UID=tasnim_DBUser;PWD=*******;";

我想用dbo创建。******

我设置了ObjectSchema但未解析

SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(serverConn, scopeDesc)
                        {
                            ObjectSchema = "dbo",
                            ObjectPrefix = "dbo"
                        };

主机是共享的,Plesk面板

编辑1: 服务器配置代码:

if (new SqlSyncScopeProvisioning(serverConn).ScopeExists("MySyncScope2")) return;
DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("MySyncScope2");
DbSyncTableDescription tableNameTableDesc = SqlSyncDescriptionBuilder.GetDescriptionForTable("tableName", serverConn);
.
.
.
scopeDesc.Tables.Add(tableNameTableDesc);
.
.
.
 try
            {
                SqlSyncScopeProvisioning serverProvision = new SqlSyncScopeProvisioning(serverConn, scopeDesc);
                serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);
                if (!serverProvision.ScopeExists("MySyncScope2")) serverProvision.Apply();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

Clint供应代码:

if (new SqlSyncScopeProvisioning(db.Con).ScopeExists("MySyncScope2")) return;
   try
            {

                DbSyncScopeDescription scopeDescClint =
                    SqlSyncDescriptionBuilder.GetDescriptionForScope("MySyncScope2", serverConn);

                SqlSyncScopeProvisioning clientProvision = new SqlSyncScopeProvisioning(db.Con, scopeDescClint);

                if (!clientProvision.ScopeExists("MySyncScope2")) clientProvision.Apply();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,db user必须具有db_owner角色并使用此查询设置默认架构“dbo”

ALTER USER dbUserName WITH DEFAULT_SCHEMA = dbo;

或在SQL server management studio / security / users / db-username /右键单击/ properties / set default schema“dbo”