SlideShare a Scribd company logo
1 of 25
Download to read offline
Local Database Caching with the Microsoft Sync Framework
presented to NUFWon 11/10/2009

DESIGNING APPLICATIONS FOR
THE OCCASIONALLY CONNECTED
SCENARIO
About Me
 Work for Systemental, Inc as a Consultant
  and Software Developer
 Software development to support Corporate
  business process improvement since 2000
  (Lean or Continuous Improvement Initiatives)
   .Net since 2004
 President, fwPASS.org
 Mfg. Eng. Technology degrees from Ball State
  University
A case study in failure

 What could go wrong preparing this
  presentation did
   Initial demo worked in minutes (after about three
    minor problems)
   SQL CE debugging challenges
  1. Refactor - created numerous problems
  2. Test - find problems requiring schema changes
  3. Repeat 1-2 ad nauseum
What we will cover

 What is the Microsoft Sync Framework?
 How you can use it?
 Why?
 How does it work?
 How do you implement it?
   Demo’s
 Gotcha’s, gotcha’s, and debugging
What is the Sync Framework

 Provider-based API for synchronizing data or
  files across multiple applications, services,
  and physical devices
 Included providers
   Database *
   File system
   Web – RSS/Atom
How can it be used?

 Server to Local
 Local to Server
 Bi-directional
Why?

 Why not pub/sub, log shipping, replication?
   Reliability
   Purpose
   schedule granularity
 Disconnected, hello….
 Argument: Internet is everywhere and growing
 CE vs. Express
   Encrypt or password protect the file
   Document-safe, no code stored in file
   Light 1.8Mb vs. 58Mb
How does it work?

 Visual Studio local database cache template
 Schema changes (couple fields and
  tombstone)
 Triggers or 2008 Change data capture
Sync Process
Steps to Implement

 Add new item - local database cache
 Create database/tables to sync or modify DDL
 Sync Configuration wizard
     Configure source/target databases
     add/edit .sdf database
     add sync tables
     Generate/run scripts to adjust ddl/sync
     Generate typed dataset/table adapters (optional)
 Generate Linq2SQL or EF classes (optional)
 Set sync direction and .Synchronize
Demo project
Keyboard Encoder Module
Demo project details

 WPF application with a single keystroke input
  F5 key
 Changing background color (green, yellow,
  red) based on actual count vs. target count
 Two dispatcher timers:
  1. Screen display color update (every second)
  2. Db synchronization (every minute)
 WinForm SQL CE cache table viewer
 Using Repository pattern and Linq to SQL
Demos

 Existing SQL db, switch to CE 3.5 using
    provider and connection string change
   Wizardry
   SQLMetal
   Profiler
   Server to local sync (default)
   local to server sync/bi-directional (code-
    behind)
SQLMetal to create Linq2SQL
classes
Gotcha’s
 Visual Studio Linq2SQL template doesn’t support SQL CE
   provider – use SQLMetal to generate, then include in project
 LINQ dbml created from MSSQL, not compatible CE
 SSMS 2005 would not open a CE 3.5 .sdf file. Need SSMS 2008
 Set sync direction if anything other than server to local
 Changing schema’s after generation – remove everything and
   start over (use sql scripts to roll back)
 Insert/Update triggers not auto created?
 .sdf is re-initialized to empty and copied to bin/debug if newer
 Existing triggers on the table
Gotcha’s – primary key

 Primary key defined on table to cache
 auto-incrementing integer primary key,
  unique identity with SQL CE db
 Some table defaults like newid() for
  MSSQL Uniqueidentifer field do not
  transfer to the .sdf schema definition. Set
  in code <table>.id=Guid.NewGuid
 Linq can’t autogenerate guid on server.
  Use id=Guid.NewGuid in code
Debugging SQL CE 3.5
•   SSMS 2005 gives the following error when you try to connect to a SQL CE 3.5 .sdf file.
•   Created a WinForm project PeekLocalCache to display data from .sdf file. Caution: make sure
    you know which .sdf file the app is using (bin/debug, bin/release, project)
•   SSMS 2008 – hopefully works
•   Be careful re-creating the .sdf file using the local database cache configuration wizard
    without deleting the records from the Server table.

                                                       I cleared out the Server table and ran for
                                                       a while on 11/2 without ex, on 11/3
                                                       cleared out the table and ran for 13
                                                       records. Changing to update server
                                                       table, works. Violation is in local cache
                                                       db
Switched PK to GUID from
Int64
Set autogen=true in dbml:
fail!
added id = Guid.NewGuid
Conflict resolution
 Sorry, not covering in Demos
 Enums – conflict types (between sync sessions)
    ClientInsertServerInsert - A new row is created with the same
       primary key.
      ClientUpdateServerUpdate - The same row is updated. Most
       common
      ClientUpdateServerDelete - A row is updated on the client but
       was deleted on the server.
      ClientDeleteServerUpdate - A row is deleted on the client but
       was updated on the server.
      ErrorsOccurred – all others
 Methods for handling
    Continue
    RetryApplyingRow
    RetryWithForceWrite
Resolution Policies

 Source wins
 Destination wins
 Specified replica wins
 Last writer wins
 Merge
 Log it or defer
References
   http://dean-o.blogspot.com/
   http://channel9.msdn.com/posts/funkyonex/Offline-Data-Synchronization-Services-in-Visual-
    Studio-2008/
   http://videoworld-rong.blogspot.com/2009/10/adonet-sync-services.html
   http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/0fd34e49-ae3d-4b50-
    91f5-5e24d4a0b145
   http://skysigal.xact-solutions.com/Blog/tabid/427/EntryId/898/Using-LinqToSQL-with-SqlServer-
    Compact.aspx
   http://download.microsoft.com/download/A/4/7/A47B7B0E-976D-4F49-B15D-
    F02ADE638EBE/Compact_Express_Comparison.doc
   http://www.developer.com/net/article.php/3815506/Handling-Data-Conflicts-in-the-Microsoft-
    Sync-Framework.htm
   http://www.geekzone.co.nz/JamesHip/6568
   http://code.msdn.microsoft.com/sync
   http://mattgoebel.spaces.live.com/blog/cns!DB12DAA600AD8227!182.entry?wa=wsignin1.0&sa=
    84900002
   http://devlicio.us/blogs/billy_mccafferty/archive/2009/11/09/dependency-injection-101.aspx
   http://stackoverflow.com/questions/385796/sync-framework-can-i-sync-only-a-subset-of-my-
    tables
   ASP.NET MVC Framework Unleashed by Stephen Walther, SAMS, ISBN 978-0-672-32998-2
Thank you!

 Website
   http://www.systemental.com
 Blogs
   http://dean-o.blogspot.com/
   http://practicalhoshin.blogspot.com
 Twitter
   http://www.twitter.com/deanwillson
 Email
   dean@systemental.com
 LinkedIn
   http://www.linkedin.com/in/deanwillson

More Related Content

What's hot

Cloud Based Data Warehousing and Analytics
Cloud Based Data Warehousing and AnalyticsCloud Based Data Warehousing and Analytics
Cloud Based Data Warehousing and AnalyticsSeeling Cheung
 
Why advanced monitoring is key for healthy
Why advanced monitoring is key for healthyWhy advanced monitoring is key for healthy
Why advanced monitoring is key for healthyDenodo
 
2012 10 bigdata_overview
2012 10 bigdata_overview2012 10 bigdata_overview
2012 10 bigdata_overviewjdijcks
 
Testing Strategies for Data Lake Hosted on Hadoop
Testing Strategies for Data Lake Hosted on HadoopTesting Strategies for Data Lake Hosted on Hadoop
Testing Strategies for Data Lake Hosted on HadoopCitiusTech
 
DATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAINING
DATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAININGDATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAINING
DATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAININGDatawarehouse Trainings
 
An introduction to data virtualization in business intelligence
An introduction to data virtualization in business intelligenceAn introduction to data virtualization in business intelligence
An introduction to data virtualization in business intelligenceDavid Walker
 
Enabling Data as a Service with the JBoss Enterprise Data Services Platform
Enabling Data as a Service with the JBoss Enterprise Data Services PlatformEnabling Data as a Service with the JBoss Enterprise Data Services Platform
Enabling Data as a Service with the JBoss Enterprise Data Services Platformprajods
 
Introduction to Microsoft’s Master Data Services (MDS)
Introduction to Microsoft’s Master Data Services (MDS)Introduction to Microsoft’s Master Data Services (MDS)
Introduction to Microsoft’s Master Data Services (MDS)James Serra
 
Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)Kent Graziano
 
Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...
Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...
Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...Denodo
 
Information Virtualization: Query Federation on Data Lakes
Information Virtualization: Query Federation on Data LakesInformation Virtualization: Query Federation on Data Lakes
Information Virtualization: Query Federation on Data LakesDataWorks Summit
 
2014.07.11 biginsights data2014
2014.07.11 biginsights data20142014.07.11 biginsights data2014
2014.07.11 biginsights data2014Wilfried Hoge
 
Service Mesh Talk for CTO Forum
Service Mesh Talk for CTO ForumService Mesh Talk for CTO Forum
Service Mesh Talk for CTO ForumRick Hightower
 
Big data insights with Red Hat JBoss Data Virtualization
Big data insights with Red Hat JBoss Data VirtualizationBig data insights with Red Hat JBoss Data Virtualization
Big data insights with Red Hat JBoss Data VirtualizationKenneth Peeples
 
Data Lake - Multitenancy Best Practices
Data Lake - Multitenancy Best PracticesData Lake - Multitenancy Best Practices
Data Lake - Multitenancy Best PracticesCitiusTech
 
Understanding Metadata: Why it's essential to your big data solution and how ...
Understanding Metadata: Why it's essential to your big data solution and how ...Understanding Metadata: Why it's essential to your big data solution and how ...
Understanding Metadata: Why it's essential to your big data solution and how ...Zaloni
 
From Traditional Data Warehouse To Real Time Data Warehouse
From Traditional Data Warehouse To Real Time Data WarehouseFrom Traditional Data Warehouse To Real Time Data Warehouse
From Traditional Data Warehouse To Real Time Data WarehouseOsama Hussein
 

What's hot (20)

Cloud Based Data Warehousing and Analytics
Cloud Based Data Warehousing and AnalyticsCloud Based Data Warehousing and Analytics
Cloud Based Data Warehousing and Analytics
 
Why advanced monitoring is key for healthy
Why advanced monitoring is key for healthyWhy advanced monitoring is key for healthy
Why advanced monitoring is key for healthy
 
2012 10 bigdata_overview
2012 10 bigdata_overview2012 10 bigdata_overview
2012 10 bigdata_overview
 
SQL Server Disaster Recovery Implementation
SQL Server Disaster Recovery ImplementationSQL Server Disaster Recovery Implementation
SQL Server Disaster Recovery Implementation
 
Testing Strategies for Data Lake Hosted on Hadoop
Testing Strategies for Data Lake Hosted on HadoopTesting Strategies for Data Lake Hosted on Hadoop
Testing Strategies for Data Lake Hosted on Hadoop
 
DATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAINING
DATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAININGDATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAINING
DATASTAGE AND QUALITY STAGE 9.1 ONLINE TRAINING
 
An introduction to data virtualization in business intelligence
An introduction to data virtualization in business intelligenceAn introduction to data virtualization in business intelligence
An introduction to data virtualization in business intelligence
 
Enabling Data as a Service with the JBoss Enterprise Data Services Platform
Enabling Data as a Service with the JBoss Enterprise Data Services PlatformEnabling Data as a Service with the JBoss Enterprise Data Services Platform
Enabling Data as a Service with the JBoss Enterprise Data Services Platform
 
Introduction to Microsoft’s Master Data Services (MDS)
Introduction to Microsoft’s Master Data Services (MDS)Introduction to Microsoft’s Master Data Services (MDS)
Introduction to Microsoft’s Master Data Services (MDS)
 
Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)Agile Methods and Data Warehousing (2016 update)
Agile Methods and Data Warehousing (2016 update)
 
DW 101
DW 101DW 101
DW 101
 
Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...
Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...
Denodo Data Virtualization Platform: Scalability (session 3 from Architect to...
 
Information Virtualization: Query Federation on Data Lakes
Information Virtualization: Query Federation on Data LakesInformation Virtualization: Query Federation on Data Lakes
Information Virtualization: Query Federation on Data Lakes
 
2014.07.11 biginsights data2014
2014.07.11 biginsights data20142014.07.11 biginsights data2014
2014.07.11 biginsights data2014
 
Service Mesh Talk for CTO Forum
Service Mesh Talk for CTO ForumService Mesh Talk for CTO Forum
Service Mesh Talk for CTO Forum
 
Data vault what's Next: Part 2
Data vault what's Next: Part 2Data vault what's Next: Part 2
Data vault what's Next: Part 2
 
Big data insights with Red Hat JBoss Data Virtualization
Big data insights with Red Hat JBoss Data VirtualizationBig data insights with Red Hat JBoss Data Virtualization
Big data insights with Red Hat JBoss Data Virtualization
 
Data Lake - Multitenancy Best Practices
Data Lake - Multitenancy Best PracticesData Lake - Multitenancy Best Practices
Data Lake - Multitenancy Best Practices
 
Understanding Metadata: Why it's essential to your big data solution and how ...
Understanding Metadata: Why it's essential to your big data solution and how ...Understanding Metadata: Why it's essential to your big data solution and how ...
Understanding Metadata: Why it's essential to your big data solution and how ...
 
From Traditional Data Warehouse To Real Time Data Warehouse
From Traditional Data Warehouse To Real Time Data WarehouseFrom Traditional Data Warehouse To Real Time Data Warehouse
From Traditional Data Warehouse To Real Time Data Warehouse
 

Similar to Local Database Caching with the Microsoft Sync Framework

SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availabilityPeter Gfader
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
PHP North-East - Automated Deployment
PHP North-East - Automated DeploymentPHP North-East - Automated Deployment
PHP North-East - Automated DeploymentMichael Peacock
 
Automated Deployment
Automated DeploymentAutomated Deployment
Automated Deploymentphpne
 
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginnersKoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginnersTobias Koprowski
 
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginnersKoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginnersTobias Koprowski
 
Database Mirror for the exceptional DBA – David Izahk
Database Mirror for the exceptional DBA – David IzahkDatabase Mirror for the exceptional DBA – David Izahk
Database Mirror for the exceptional DBA – David Izahksqlserver.co.il
 
MS Cloud Day - Deploying and monitoring windows azure applications
MS Cloud Day - Deploying and monitoring windows azure applicationsMS Cloud Day - Deploying and monitoring windows azure applications
MS Cloud Day - Deploying and monitoring windows azure applicationsSpiffy
 
Pro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperPro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperJens Vestergaard
 
Db As Behaving Badly... Worst Practices For Database Administrators Rod Colledge
Db As Behaving Badly... Worst Practices For Database Administrators Rod ColledgeDb As Behaving Badly... Worst Practices For Database Administrators Rod Colledge
Db As Behaving Badly... Worst Practices For Database Administrators Rod Colledgesqlserver.co.il
 
Sql 2012 always on
Sql 2012 always onSql 2012 always on
Sql 2012 always ondilip nayak
 
Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011
Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011
Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011Michael Noel
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Antonios Chatzipavlis
 
Upgrade to 2008 Best of PASS
Upgrade to 2008 Best of PASSUpgrade to 2008 Best of PASS
Upgrade to 2008 Best of PASSsqlserver.co.il
 
The two faces of sql parameter sniffing
The two faces of sql parameter sniffingThe two faces of sql parameter sniffing
The two faces of sql parameter sniffingIvo Andreev
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesdrupalindia
 

Similar to Local Database Caching with the Microsoft Sync Framework (20)

SQL Server - High availability
SQL Server - High availabilitySQL Server - High availability
SQL Server - High availability
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
PHP North-East - Automated Deployment
PHP North-East - Automated DeploymentPHP North-East - Automated Deployment
PHP North-East - Automated Deployment
 
Automated Deployment
Automated DeploymentAutomated Deployment
Automated Deployment
 
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginnersKoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
 
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginnersKoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
 
North east user group tour
North east user group tourNorth east user group tour
North east user group tour
 
Database Mirror for the exceptional DBA – David Izahk
Database Mirror for the exceptional DBA – David IzahkDatabase Mirror for the exceptional DBA – David Izahk
Database Mirror for the exceptional DBA – David Izahk
 
MS Cloud Day - Deploying and monitoring windows azure applications
MS Cloud Day - Deploying and monitoring windows azure applicationsMS Cloud Day - Deploying and monitoring windows azure applications
MS Cloud Day - Deploying and monitoring windows azure applications
 
Pro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD DeveloperPro Techniques for the SSAS MD Developer
Pro Techniques for the SSAS MD Developer
 
Db As Behaving Badly... Worst Practices For Database Administrators Rod Colledge
Db As Behaving Badly... Worst Practices For Database Administrators Rod ColledgeDb As Behaving Badly... Worst Practices For Database Administrators Rod Colledge
Db As Behaving Badly... Worst Practices For Database Administrators Rod Colledge
 
Sql 2012 always on
Sql 2012 always onSql 2012 always on
Sql 2012 always on
 
Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011
Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011
Building the Perfect SharePoint 2010 Farm - TechEd Australia 2011
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
 
2007 SAPTech Ed
2007 SAPTech Ed2007 SAPTech Ed
2007 SAPTech Ed
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
 
Upgrade to 2008 Best of PASS
Upgrade to 2008 Best of PASSUpgrade to 2008 Best of PASS
Upgrade to 2008 Best of PASS
 
The two faces of sql parameter sniffing
The two faces of sql parameter sniffingThe two faces of sql parameter sniffing
The two faces of sql parameter sniffing
 
DevOps and Chef improve your life
DevOps and Chef improve your life DevOps and Chef improve your life
DevOps and Chef improve your life
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 

More from Dean Willson

Intro to the Internet of Things using Netduino
Intro to the Internet of Things using NetduinoIntro to the Internet of Things using Netduino
Intro to the Internet of Things using NetduinoDean Willson
 
Index Reorganization and Rebuilding for Success
Index Reorganization and Rebuilding for SuccessIndex Reorganization and Rebuilding for Success
Index Reorganization and Rebuilding for SuccessDean Willson
 
Automating sql server daily health checks
Automating sql server daily health checksAutomating sql server daily health checks
Automating sql server daily health checksDean Willson
 
Visual Studio 2012 Productivity Tools
Visual Studio 2012 Productivity ToolsVisual Studio 2012 Productivity Tools
Visual Studio 2012 Productivity ToolsDean Willson
 
Intro to Powershell
Intro to PowershellIntro to Powershell
Intro to PowershellDean Willson
 
Continuous improvement in a professional organization
Continuous improvement in a professional organizationContinuous improvement in a professional organization
Continuous improvement in a professional organizationDean Willson
 
Database Source Control
Database Source ControlDatabase Source Control
Database Source ControlDean Willson
 
Career Transitions - Ball State University, Six Sigma Speakers Series
Career Transitions - Ball State University, Six Sigma Speakers SeriesCareer Transitions - Ball State University, Six Sigma Speakers Series
Career Transitions - Ball State University, Six Sigma Speakers SeriesDean Willson
 
Introduction to SQL Server 2008 Management Data Warehouse (MDW)
Introduction to SQL Server 2008 Management Data Warehouse (MDW)Introduction to SQL Server 2008 Management Data Warehouse (MDW)
Introduction to SQL Server 2008 Management Data Warehouse (MDW)Dean Willson
 
Implementing ASP.NET Role Based Security
Implementing ASP.NET Role Based SecurityImplementing ASP.NET Role Based Security
Implementing ASP.NET Role Based SecurityDean Willson
 
Introduction to SSRS Report Builder
Introduction to SSRS Report BuilderIntroduction to SSRS Report Builder
Introduction to SSRS Report BuilderDean Willson
 
Data Mining with SQL Server 2005
Data Mining with SQL Server 2005Data Mining with SQL Server 2005
Data Mining with SQL Server 2005Dean Willson
 

More from Dean Willson (12)

Intro to the Internet of Things using Netduino
Intro to the Internet of Things using NetduinoIntro to the Internet of Things using Netduino
Intro to the Internet of Things using Netduino
 
Index Reorganization and Rebuilding for Success
Index Reorganization and Rebuilding for SuccessIndex Reorganization and Rebuilding for Success
Index Reorganization and Rebuilding for Success
 
Automating sql server daily health checks
Automating sql server daily health checksAutomating sql server daily health checks
Automating sql server daily health checks
 
Visual Studio 2012 Productivity Tools
Visual Studio 2012 Productivity ToolsVisual Studio 2012 Productivity Tools
Visual Studio 2012 Productivity Tools
 
Intro to Powershell
Intro to PowershellIntro to Powershell
Intro to Powershell
 
Continuous improvement in a professional organization
Continuous improvement in a professional organizationContinuous improvement in a professional organization
Continuous improvement in a professional organization
 
Database Source Control
Database Source ControlDatabase Source Control
Database Source Control
 
Career Transitions - Ball State University, Six Sigma Speakers Series
Career Transitions - Ball State University, Six Sigma Speakers SeriesCareer Transitions - Ball State University, Six Sigma Speakers Series
Career Transitions - Ball State University, Six Sigma Speakers Series
 
Introduction to SQL Server 2008 Management Data Warehouse (MDW)
Introduction to SQL Server 2008 Management Data Warehouse (MDW)Introduction to SQL Server 2008 Management Data Warehouse (MDW)
Introduction to SQL Server 2008 Management Data Warehouse (MDW)
 
Implementing ASP.NET Role Based Security
Implementing ASP.NET Role Based SecurityImplementing ASP.NET Role Based Security
Implementing ASP.NET Role Based Security
 
Introduction to SSRS Report Builder
Introduction to SSRS Report BuilderIntroduction to SSRS Report Builder
Introduction to SSRS Report Builder
 
Data Mining with SQL Server 2005
Data Mining with SQL Server 2005Data Mining with SQL Server 2005
Data Mining with SQL Server 2005
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Local Database Caching with the Microsoft Sync Framework

  • 1. Local Database Caching with the Microsoft Sync Framework presented to NUFWon 11/10/2009 DESIGNING APPLICATIONS FOR THE OCCASIONALLY CONNECTED SCENARIO
  • 2. About Me  Work for Systemental, Inc as a Consultant and Software Developer  Software development to support Corporate business process improvement since 2000 (Lean or Continuous Improvement Initiatives)  .Net since 2004  President, fwPASS.org  Mfg. Eng. Technology degrees from Ball State University
  • 3. A case study in failure  What could go wrong preparing this presentation did  Initial demo worked in minutes (after about three minor problems)  SQL CE debugging challenges 1. Refactor - created numerous problems 2. Test - find problems requiring schema changes 3. Repeat 1-2 ad nauseum
  • 4. What we will cover  What is the Microsoft Sync Framework?  How you can use it?  Why?  How does it work?  How do you implement it?  Demo’s  Gotcha’s, gotcha’s, and debugging
  • 5. What is the Sync Framework  Provider-based API for synchronizing data or files across multiple applications, services, and physical devices  Included providers  Database *  File system  Web – RSS/Atom
  • 6. How can it be used?  Server to Local  Local to Server  Bi-directional
  • 7. Why?  Why not pub/sub, log shipping, replication?  Reliability  Purpose  schedule granularity  Disconnected, hello….  Argument: Internet is everywhere and growing  CE vs. Express  Encrypt or password protect the file  Document-safe, no code stored in file  Light 1.8Mb vs. 58Mb
  • 8. How does it work?  Visual Studio local database cache template  Schema changes (couple fields and tombstone)  Triggers or 2008 Change data capture
  • 10. Steps to Implement  Add new item - local database cache  Create database/tables to sync or modify DDL  Sync Configuration wizard  Configure source/target databases  add/edit .sdf database  add sync tables  Generate/run scripts to adjust ddl/sync  Generate typed dataset/table adapters (optional)  Generate Linq2SQL or EF classes (optional)  Set sync direction and .Synchronize
  • 13. Demo project details  WPF application with a single keystroke input F5 key  Changing background color (green, yellow, red) based on actual count vs. target count  Two dispatcher timers: 1. Screen display color update (every second) 2. Db synchronization (every minute)  WinForm SQL CE cache table viewer  Using Repository pattern and Linq to SQL
  • 14. Demos  Existing SQL db, switch to CE 3.5 using provider and connection string change  Wizardry  SQLMetal  Profiler  Server to local sync (default)  local to server sync/bi-directional (code- behind)
  • 15. SQLMetal to create Linq2SQL classes
  • 16. Gotcha’s  Visual Studio Linq2SQL template doesn’t support SQL CE provider – use SQLMetal to generate, then include in project  LINQ dbml created from MSSQL, not compatible CE  SSMS 2005 would not open a CE 3.5 .sdf file. Need SSMS 2008  Set sync direction if anything other than server to local  Changing schema’s after generation – remove everything and start over (use sql scripts to roll back)  Insert/Update triggers not auto created?  .sdf is re-initialized to empty and copied to bin/debug if newer  Existing triggers on the table
  • 17. Gotcha’s – primary key  Primary key defined on table to cache  auto-incrementing integer primary key, unique identity with SQL CE db  Some table defaults like newid() for MSSQL Uniqueidentifer field do not transfer to the .sdf schema definition. Set in code <table>.id=Guid.NewGuid  Linq can’t autogenerate guid on server. Use id=Guid.NewGuid in code
  • 18. Debugging SQL CE 3.5 • SSMS 2005 gives the following error when you try to connect to a SQL CE 3.5 .sdf file. • Created a WinForm project PeekLocalCache to display data from .sdf file. Caution: make sure you know which .sdf file the app is using (bin/debug, bin/release, project) • SSMS 2008 – hopefully works • Be careful re-creating the .sdf file using the local database cache configuration wizard without deleting the records from the Server table. I cleared out the Server table and ran for a while on 11/2 without ex, on 11/3 cleared out the table and ran for 13 records. Changing to update server table, works. Violation is in local cache db
  • 19. Switched PK to GUID from Int64
  • 20. Set autogen=true in dbml: fail!
  • 21. added id = Guid.NewGuid
  • 22. Conflict resolution  Sorry, not covering in Demos  Enums – conflict types (between sync sessions)  ClientInsertServerInsert - A new row is created with the same primary key.  ClientUpdateServerUpdate - The same row is updated. Most common  ClientUpdateServerDelete - A row is updated on the client but was deleted on the server.  ClientDeleteServerUpdate - A row is deleted on the client but was updated on the server.  ErrorsOccurred – all others  Methods for handling  Continue  RetryApplyingRow  RetryWithForceWrite
  • 23. Resolution Policies  Source wins  Destination wins  Specified replica wins  Last writer wins  Merge  Log it or defer
  • 24. References  http://dean-o.blogspot.com/  http://channel9.msdn.com/posts/funkyonex/Offline-Data-Synchronization-Services-in-Visual- Studio-2008/  http://videoworld-rong.blogspot.com/2009/10/adonet-sync-services.html  http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/0fd34e49-ae3d-4b50- 91f5-5e24d4a0b145  http://skysigal.xact-solutions.com/Blog/tabid/427/EntryId/898/Using-LinqToSQL-with-SqlServer- Compact.aspx  http://download.microsoft.com/download/A/4/7/A47B7B0E-976D-4F49-B15D- F02ADE638EBE/Compact_Express_Comparison.doc  http://www.developer.com/net/article.php/3815506/Handling-Data-Conflicts-in-the-Microsoft- Sync-Framework.htm  http://www.geekzone.co.nz/JamesHip/6568  http://code.msdn.microsoft.com/sync  http://mattgoebel.spaces.live.com/blog/cns!DB12DAA600AD8227!182.entry?wa=wsignin1.0&sa= 84900002  http://devlicio.us/blogs/billy_mccafferty/archive/2009/11/09/dependency-injection-101.aspx  http://stackoverflow.com/questions/385796/sync-framework-can-i-sync-only-a-subset-of-my- tables  ASP.NET MVC Framework Unleashed by Stephen Walther, SAMS, ISBN 978-0-672-32998-2
  • 25. Thank you!  Website  http://www.systemental.com  Blogs  http://dean-o.blogspot.com/  http://practicalhoshin.blogspot.com  Twitter  http://www.twitter.com/deanwillson  Email  dean@systemental.com  LinkedIn  http://www.linkedin.com/in/deanwillson

Editor's Notes

  1. SQL CE – winform db reader or SSMS 2008
  2. Show scripts or look at triggers in db. Homework assignment: See how SS knows the .sdf has changes to upload to server. No SS 2008 to look at the schema or attach to Profiler.
  3. SQL Profiler
  4. Auto-incrementing integer can cause inserting into client and server with the same primary key
  5. I was using bigint as the PK, Unique Identifier. This led to intermittent results. Use Guid instead. Apparently SQL CE *doesn’t* support server generated ID’s.