local database synchronization between sql server database and local sql ce database - c#

Im implementing application in which there is local database which uses SQL CE. Each time app starts there has to be synchronization between local database and server database (to have new values in dictionary tables).
Problem is that mappings are different in sql ce and sql server 2008 when using entity framework.
Is it common problem ? is there any way to automate that ?
Do you know about any good pattern ?
thanks for help,
bye

You can use Merge replication, which supports (almost) all SQL Server 2008 datatypes.
Issues relating to EF seem to be unrelated, can you elaborate... You must create the model based on a SQL Compact database, you cannot use a model created against a SQL Server database with a SQL Compact database

Have you tried ADO.Net Synchronization framework? See here

Related

Need to copy an entire table from SQL Server to SQL Server CE including the table structure and all data

I'm looking to copy tables including all their data from SQL Server to a SQL CE database in C# on demand.
The trick is, the tables being copied will not be known until runtime and will not previously exist in the SQL CE database.
I'm hoping to do this by getting a DataTable from the server first and then copying that into the CE database.
What is the simplest way to insert that new table and its data to the SQL Server CE database?
And is there an alternative method I should consider?
The method would have to work on any version of SQL Server from 2005 and up so I cannot rely on a feature only available in newer versions.
The local DB will always be blank.
The tables may contain up to several thousand records and this is going to be used as a local cache.
Thanks in advance
What I've done so far and tested on a sample project is:
Get the data into a DataTable from SQL Server
Create a create table script using the DataTable's column collection
Run that against my SQL Server CE database
And found a library written by someone else to do a bulk copy into the CE database since the regular SQL bulk copy does not support CE.
I need to integrate it into the main app and test it against real production data to see how it performs, but provided that is acceptable I'm going this route I think.

Where does code first entity framework save data

Ok so i know I'm fairly new to C# and MVC but I'm trying to use the code first approach of adding items to a database.
Now I have successfully created new entries to the database but when I go to SQL Server i cannot find the database or tables.
So my question is where is this data being stored as I can't see it in SQL Server like my other databases that I manually created?
My ConnectionString is:
Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-Testing-20140809020449.mdf;Initial Catalog=aspnet-Testing-20140809020449;Integrated Security=True
LocalDb is the new server-less version of SQL Server that has similar features as SQL Express. I would describe it as a just-in-time version of SQL Server that is only running when needed.
In order to connect to it usng SQL Server Management Studio, you need to connect using the following connection string (assming SQL Server Version 11/2014 may change to 12 or higher in future versions):
Then you'll have access to the database.
[project_dir]\App_Data\aspnet-Testing-20140809020449.mdf

Linq-to-SQL (dbml) with Local database cache (C#+VS2010)

I'm developing a WPF application, which connects MS SQL2008 database remotely.
The app communicates with the database by Linq-to-SQL. pretty handy.
However, because of the slow database server, I'm trying to use local database caching.
"VS2010 > Add Item > Local database cache" wizard could be a solution, but it uses DataSet and SQL Compact(*.sdf).
I found Linq-To-SQL cannot generate classes from the SQL COMPACT edition!
(when I drag tables, error pops up and says 'unsupported data provider')
So, is there any solution to use Linq-to-SQL with local database cache?
or is there any database sync method played with Linq-to-SQL?
If you still want to go the sql compact way, Lightspeed is a linq-to-sql provider that supports a variety of data-sources. it includes mssql compact.
http://www.mindscapehq.com/products/lightspeed
The free version is sufficient for most projects, with an 8 model/class limit.
Ive used it as a linq provider for MySql and Sql Compact before and it's been great.
You can see everything it supports and how it compares to other existing systems like it here:
http://www.mindscapehq.com/products/lightspeed/comparing-lightspeed
the Local Database Cache Wizard only supports SQL Ce on the client side. if you have SQL Express/SQL Server on the client side, you can use Sync Framework still.
see following samples/tutorials using Sync Framework:
Synchronizing SQL Server and SQL Express
Database Sync:SQL Server and SQL Express 2-Tier
nevermind if it mentions SQLExpress, the SQLSyncProvider referenced in the code should work against SQL Express,SQL Server, and SQL Azure

Synchronization MSSQL databases with selected data in .NET

We have database SQL server 2008 (db A). For better performance we will use next SQL server 2008 databases with the one workgroup (db B, C, ...). These databases will contain only necessary records and will can save some special records. These all databases are always full SQL server, not express.
So we need to synchronize data from db A to db B, C. And then we need synchronize some data (with special sql query - for example only completed orders, not all) from db B to db A, from db C to db A, etc.
The synchronization should be console application.
I found some examples used MS Sync Framwork:
SyncOrchestrator but I don't know how to select only some tables and some records.
SyncTable but here I don't know how correct set RemoteProvider and LocalProvider to database SQL server 2008.
Is there any way how to solve it? Or how can I correct use sync?
Sorry for my english, it's not my native language.
Many thanks.
check out the walkthroughs here: http://msdn.microsoft.com/en-us/library/ff928700(v=SQL.110).aspx
(the same walkthrough is in the documentation if you download Sync Framework 2.1)
that should get you up and running with defining a scope for your selected tables with filtering applied and specifying both local and remote providers as well. While the walkthrough says synchronizing between Sql Server and Sql Express, you can use the same for Sql Server to Sql Server synchronization as Sql Express, Sql Server and Sql Azure uses the same SqlSyncProvider.
I would use SQL Server Replication http://msdn.microsoft.com/en-us/library/ms151198.aspx

Regarding MS-Sync framework

with the help of MS-Sync framework can i sync data between two sql server table in two different database. i hard MS-Sync framework used to sync data between sql server & sql server CE database. give me url from where i can have the idea of sync data between two table in two different database.
try this: Tutorial: Synchronizing SQL Server and SQL Express, it should work with SQl

Categories

Resources