Answered by:
__sysChangeTxBsn Column in Sql Server Compact with Sync services

Question
-
I've set up a sync database using SQL Server compact and am getting errors regarding the __sysChangeTxBsn. I have two questions:
1) Why can't I see the __sysChangeTxBsn column in my tables when I use Server Explorer in Visual Studio?
2) I try a Snapshot sync and it seems to work. But as soon as I start working with my application, I get this error:
{"The column name is not valid. [ Node name (if any) = Extent1,Column name = __sysChangeTxBsn ]"}
Thanks,
Reese- Moved by Max Wang_1983 Thursday, April 21, 2011 10:35 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
Wednesday, November 18, 2009 5:50 PM
Answers
-
One of the possiblity could be that wpf datagrid doesnot support column name starting with "_" character. I am not too familiar with wpf datagrid. Can you try adding new user column name with "_" character and verifyif this is the issue. If your sql query for datagrid is "select * ...", I would suggest you to add columns to the query explicity (excluding column __sysChangeTxBsn) instead of * all.
Let us know if this helps.
Thanks
Jandeep
jandeepcThursday, November 19, 2009 6:12 PM -
Hi Reese,
Sync Framework supports Side by Side with 1.0 and 2.0. So you can install 2.0 binaries. But you will have to recompile your app against new Sync framework binaries.
thanks
Jandeep
jandeepc- Marked as answer by Dong CaoMicrosoft employee, Moderator Sunday, November 22, 2009 5:16 AM
Friday, November 20, 2009 5:55 PM
All replies
-
1. This is by Design.. Since it used for internal change tracking. it has not been exposed.
2. Please provide more details on the scenario (how did you do sanpshot) and also the exception stack trace.
thanks
Jandeep
jandeepc- Proposed as answer by Jandeep Wednesday, November 18, 2009 7:22 PM
Wednesday, November 18, 2009 7:02 PM -
Jandeep,
Here are the commands I use to run the snapshot sync:
JotToGoCacheSyncAgent syncAgent = new JotToGoCacheSyncAgent();
JotToGoCacheClientSyncProvider clientSyncProvider = (JotToGoCacheClientSyncProvider)syncAgent.LocalProvider;
clientSyncProvider.AddHandlers();
this.DealersToGo.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Snapshot ;
this.EventsToGo.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Snapshot;
this.ContactsToGo.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Snapshot;
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
MessageBox.Show("Changes downloaded: " + syncStats.TotalChangesDownloaded.ToString() + System.Environment.NewLine + "Changes uploaded: " + syncStats.TotalChangesUploaded.ToString());
This works, in that I get the message that says 1268 records downloaded. And my ap works initially. But when I click on a WPF datagrid line, then I get the error below. Here's the exception detail - I hope this is what you mean by exception stack trace:
System.Windows.Markup.XamlParseException occurred
Message="Failed object initialization (ISupportInitialize.EndInit). Exception has been thrown by the target of an invocation. Error at object 'mainviewmodel' in markup file 'JotToGo;component/app.xaml' Line 143 Position 29."
Source="PresentationFramework"
LineNumber=143
LinePosition=29
NameContext="Resources"
StackTrace:
at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
InnerException: System.Reflection.TargetInvocationException
Message="Exception has been thrown by the target of an invocation."
Source="PresentationFramework"
StackTrace:
at System.Windows.Data.ObjectDataProvider.CreateObjectInstance(Exception& e)
at System.Windows.Data.ObjectDataProvider.QueryWorker(Object obj)
at System.Windows.Data.ObjectDataProvider.BeginQuery()
at System.Windows.Data.DataSourceProvider.EndDefer()
at System.Windows.Data.DataSourceProvider.EndInit()
at System.Windows.Data.DataSourceProvider.System.ComponentModel.ISupportInitialize.EndInit()
at System.Windows.Markup.BamlRecordReader.ElementEndInit(Object& element)
InnerException: System.Data.EntityCommandExecutionException
Message="An error occurred while executing the command definition. See the inner exception for details."
Source="System.Data.Entity"
StackTrace:
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at JotToGo.ViewModels.TaskViewModel.LoadtoList() in C:\Visual Studio Projects\JotToGo\ViewModels\TaskViewModel.cs:line 143
at JotToGo.ViewModels.TaskViewModel.LoadtoOC() in C:\Visual Studio Projects\JotToGo\ViewModels\TaskViewModel.cs:line 152
at JotToGo.ViewModels.MainViewModel..ctor() in C:\Visual Studio Projects\JotToGo\ViewModels\MainViewModel.cs:line 25
InnerException: System.Data.SqlServerCe.SqlCeException
Message="The column name is not valid. [ Node name (if any) = Extent1,Column name = __sysChangeTxBsn ]"
Source="SQL Server Compact ADO.NET Data Provider"
HResult=-2147217900
NativeError=25503
StackTrace:
at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
InnerException:Wednesday, November 18, 2009 7:35 PM -
Here's some more information that is pertinent.
The client database uses Entity Framework. The specific command that generates the error above is this:
var
where JE is the ObjectContext
and Tasks is the ObjectQuery
So, when I try to reload the ObjectQuery after a snapshot sync is when I get the error.Thursday, November 19, 2009 2:02 PM -
One of the possiblity could be that wpf datagrid doesnot support column name starting with "_" character. I am not too familiar with wpf datagrid. Can you try adding new user column name with "_" character and verifyif this is the issue. If your sql query for datagrid is "select * ...", I would suggest you to add columns to the query explicity (excluding column __sysChangeTxBsn) instead of * all.
Let us know if this helps.
Thanks
Jandeep
jandeepcThursday, November 19, 2009 6:12 PM -
Jandeep,
Thanks for the response.
Good thought, but I don't think it's the column name is the problem. The application works just fine when I do a Bidriectional Sync. I'm able to do multiples syncs and multiple data edits with the current datagrid (which is actually an Xceed WPF datagrid). So, I don't think the datagrid is the problem. I'm pretty sure that there's some conflict between the Entity Framework and the status of the data after I do a snapshot update.
In regards to the "Select *" suggestion, there may be some possibility there. I'm currently using LINQ to Entities to retrieve the data, and I am selecting all the columns. I'll try selecting just the columns I use.
Here's some related questions: I've seen that Sync Framework 2.0 has come out and I wonder if maybe it will work better with the Entity Framework.
Is that an easy upgrade to Sync Framework 2.0 from 1.0?
If I upgrade, will the upgrade routine automatically upgrade both the Sync Framework and the ADO Sync Services?
Thanks,
ReeseFriday, November 20, 2009 1:20 PM -
Hi Reese,
Sync Framework supports Side by Side with 1.0 and 2.0. So you can install 2.0 binaries. But you will have to recompile your app against new Sync framework binaries.
thanks
Jandeep
jandeepc- Marked as answer by Dong CaoMicrosoft employee, Moderator Sunday, November 22, 2009 5:16 AM
Friday, November 20, 2009 5:55 PM -
Jandeep,
The response essentially worked, but I did want to clarify the solution for anybody else. In hindsight, it seems like an obvious thing to try, given the error I was receiving.
I didn't even need to modify a "select" query. All I did was to remove the C__sysChangeTxBsn and C__sysInsertTxBsn fields from my Entity Model. They had been auto-generated and had not caused any problems on the normal Bidirectional sync. But when I did a snapshot Sync, that's when I got the error.
So, thanks.
ReeseSunday, November 22, 2009 9:56 PM