Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 同步框架。替换SQL Server CE 4.0中的PK_C#_Sql Server Ce_Microsoft Sync Framework - Fatal编程技术网

C# 同步框架。替换SQL Server CE 4.0中的PK

C# 同步框架。替换SQL Server CE 4.0中的PK,c#,sql-server-ce,microsoft-sync-framework,C#,Sql Server Ce,Microsoft Sync Framework,我尝试从两个SQL Server CE 4.0上载到主SQL Server表: CREATE TABLE [Patient] ( [Guid] uniqueidentifier NOT NULL ROWGUIDCOL DEFAULT NEWID() , [Id] int IDENTITY (1,1) NOT NULL Primary key ) 这里的Guid过去是用于同步的PK,所以在配置方法中我会(查看): var clientScope=new DbSyncScopeDescri

我尝试从两个SQL Server CE 4.0上载到主SQL Server表:

CREATE TABLE [Patient] 
(
  [Guid] uniqueidentifier NOT NULL ROWGUIDCOL DEFAULT NEWID() 
, [Id] int IDENTITY (1,1) NOT NULL Primary key
)
这里的Guid过去是用于同步的PK,所以在配置方法中我会(查看):

var clientScope=new DbSyncScopeDescription(范围);
var patTable=sqlcesyncddescriptionbuilder.GetDescriptionForTable(“患者”,clientConn);
docTable.GlobalName=docTbl;
clientScope.Tables.Add(patTable);
//删除标识列PK,因为我们不需要同步它
patTable.Columns[“Guid”]。IsPrimaryKey=true;
patTable.Columns.Remove(patTable.Columns[“Id”]);
var clientProvision=new SqlCeSyncScopeProvisioning(clientConn,clientScope);
clientProvision.ObjectPrefix=前缀;
如果(!clientProvision.ScopeExists(scope))
{

clientProvision.Apply();//调试时,您在表的PKColumns属性上看到了什么?正如预期的那样[0]{PK列名:“Guid”类型:“uniqueidentifier”}尝试移动clientScope.Tables.Add(patTable);就在此行var clientProvision=new SqlCeSyncOpeProvisioning(clientConn,clientScope)之前;这似乎不适用于SqlCeSyncProvider。不知何故,它在设置期间重新查询表以获取PK统计数据,并找到旧PK,但在范围定义中找不到它。
var clientScope = new DbSyncScopeDescription(scope);
var patTable = SqlCeSyncDescriptionBuilder.GetDescriptionForTable("Patient", clientConn);
docTable.GlobalName = docTbl;
clientScope.Tables.Add(patTable);

// remove the identity column PK since we dont need to sync it
patTable.Columns["Guid"].IsPrimaryKey = true;
patTable.Columns.Remove(patTable.Columns["Id"]);

var clientProvision = new SqlCeSyncScopeProvisioning(clientConn, clientScope);
clientProvision.ObjectPrefix = prefix;

if (!clientProvision.ScopeExists(scope))
{
    clientProvision.Apply(); // <- key not found exception in Microsoft.Synchronization.Data.SqlServerCe.dll
    Console.WriteLine("Provisioned");
}