SQL Server Express database replication/synchronization - c#

Situation:
Hi, I'm coding using Lightswitch (C#) and am thinking of deploying to multiple sites the same application and database.
The databases need to be synchronized/replicated to each other so each would have a merged database. However connectivity between the sites is not going to be 100%, so the synchronization/replication would be done whenever the connection is possible.
Question:
Would it be possible to accomplish this through SQL Server Express? If not, what would be the best way to accomplish this by code? Thanks!

SQL Server Express 2008 can be a subscriber but not a publisher, see details here:
Replication Considerations (SQL Server Express)
Microsoft SQL Server 2008 Express (SQL Server Express) can serve as a
Subscriber for all types of replication, providing a convenient way to
distribute data to client applications that use SQL Server Express.
When using SQL Server Express in a replication topology, consider the
following:
SQL Server Express cannot serve as a Publisher or Distributor.

SQL Express doesn't support replication (except as a subscriber, as Davide pointed out). I think your best bet would probably be a windows service that keeps track of table names and the most recent timestamp processed.
Integration Services is also an option if you have a server to run it on.
Do you need data to be moving one-way or both ways?

Related

Easy way to keep two SQL Servers synced if you have read only access to publisher (source) of data

I am making C# app that rely on data from one old SQL Server 2005 machine.
Since I have only acces to read only data from that server, I need to build up some kind of handmade replication.
My app is going to use SQL Server 2012 and I am planing to read data from old SQL server in nightly tasks.
Before I start reinventing the well for sync data between two SQL Servers, I'll love to try to find some kind of library or system which can do the JOB.
Unfortunately I can't just setup replication between two SQL Servers because source of data is at SQL Server 2005 version and I do not have admin rights on that server.
I just need few tables to keep sync (updated) at my new SQL Server.
Is there some kind of embedded replication which can be called from code, and which have no needs for writing and admin access to publisher database?

Use SQL Server CE 4.0 multiuser and different processes

I searched the WWW and found different answers. sometimes I read articles about the SQL Server CE 4.0 and the multiuser ability. But I can not use it with different processes or on different machines at the same time. Unfortunately, I used SQL Server CE and now I need exact that feature. Is there a way to do it? Or is the only way to use a SQL Server Express edition or another file base db like sqlite to avoid a complete code change?
Update: yes, all users need to read and write!
Thanks for any suggestions!
tro
Use SQL Server Express (or any other edition), not a filebased database for this scenario.

SQL Server Express Database hosted on Network Share - Is it Possible?

I've started work on a project that requires an SQL Server Database. I will be building a front end application in c# .Net 3.5, that will use LINQ to SQL.
I need to host the database on a network share so that a group of users can all gain access to the database, mainly for read only.
I know that SQL Server Compact is designed to run on the local machine and my company is not willing to front the costs of a full blooded SQL Server.
Is there a way of achieving what I need to do via SQL Server Express?
If so, which are the best guides on how to set this up?
Thanks
If you go with the (free) SQL Server express, it will do what you need - but you don't access it thru a network shared drive - the server would be located by an ip address (or equivalent DNS).
You c# application would be talking to a service - SQL Server - not reading to/from a database file. The service will handle the interaction with the database. Only the SQL Server service will need to know where the file actually is - your client machines won't know and shouldn't care.
If your background is only with file-based databases - i.e. MS Access, you need to change your mindset a bit about how SQL server works.
You can install a SQL Server Express instance and install the SQL Management Studio Express for all users who need access to the database. The Express Edition is a standard SQL server with limitations regarding the number of processors used, the maximum amount of memory used and the maximum database size. If these limitations don't bother you, it should work fine for you.
Using a network share as a database storage to access db files from several clients is a bad idea, as the sql server instance should always be the only one directly accessing the database, both for read and write access. Configuring several instances of SQL Server to access the same database will probably not work - and if it works, it will probably create havoc in your database files.

Changing from using EF code-first SQL Server Express approach to using standard Management Studio

I have been developing an application over the last few months using EF code first approach with SQL Server Express. It has been great but now I am ready to deploy my application to a live server I need to be able to begin using EF with a standard SQL Server Management Studio database.
I have scripted the db from my personal instance of SQL Server Express and created the db on the live server via management studio. I have also copied the data from the EdmMetadata table to the live db.
Will I be able to continue using DbContext the same way as before and simply change the connection string? I assume I won't so what are the issues facing this?
YES OF COURSE!
SQL Server (Express or Standard or Enterprise editions) are absolutely 100% binary compatible - SQL Server Express IS a full-blown SQL Server edition, same code-base as the other editions, only with some "artificial" (marketing-induced) limitations....
You could even create a BACKUP from your SQL Server Express (to a .bak file) and restore that back onto a "full-blown" SQL Server edition - works flawlessly.
And YES - EF can absolutely connect to a full-blown SQL Server, too - with all three coding approaches (database-first, model-first, code-first). All you need to change is your SQL Server connection string that you have stored somewhere.

which lightweight SQL Server type could I use on my Dev machine for a C# VS2010 project?

Which lightweight SQL Server type could I use on my Dev machine for a C# VS2010 project? (e.g. sql server express, sql server ce, full version etc).
That is, I'm running on a VMWare fusion instance on my MacBook, and just want something to develop against for a C# VS2010 project. I'm planning on having a simple database (not many tables) but will use Entity Framework.
I haven't used SQL Server before so a quick pointer re what is the best database admin interface/app to use for the version you recommend (e.g. to create database, tables etc).
You'll probably have the least friction/most support with SQL Server Express here. Since you're using Visual Studio, you can do all the table/database creation completely inside VS, no need for another tool.
There's a walkthrough of creating a database here, and a lot more info about Visual Studio's database abilities here.
It totally depends. For simple work, express is ok. I prefer to still install the dev version for the management tools.
Otherwise just go with the dev version - you have no choice if oyu want more than simple standard SQL on your server anyway. Unless you USE it, sql server is pretty leightweight.
SQL Server CE (Compact Edition) is the lightest-weight version of SQL Server available. The database is stored in a single file (.sdf) and the database engine is hosted in-process (e.g. it's not a separate Windows service). While it supports most standard SQL, there are more advanced features that it does not support, like stored procedures (see more in this PDF). Additionally, there are limitations when using Entity Framework with SQL CE (see here).
SQL Express is much more like full SQL Server, but it does require running separate services on your machine, and it does use more resources than SQL CE. If you plan to transition to using full-on SQL Server at some point, then going with SQL Express is your safest bet.
You can use Visual Studio's built-in Server Explorer to administer whatever type of database you have setup, or, alternatively, you can use SQL Server Management Studio (Express), which is more powerful. I'm not sure if it can be used to administer SQL CE databases.

Categories