Search code examples
sql-server-cesql-server-ce-4

Sharing a SQL CE 4 database between projects


I have one solution in VS2010 containing two MVC 3 projects. These are two distinct applications that must act on the same data, so I need my database to be shared between these projects.

I would like to use SQL CE 4, but since it is an in-memory, local database, I could not figure out a way to make it available for two different projects. All tutorials I've come across so far suggest that you place your SDF file in the App_Data folder, which won't work out for my case.

Have any of you managed to do that yet?

Thanks in advance!


Solution

  • While it is possible (read: Hardlinks) to make a SQL CE database available to two apps, it is not a good idea, if even one of them writes. To make that clear: N readers work, N readers + 1 Writer do not work (bad reads, random crashes). N writers for N>1 results in a corrupted file.

    The typical way round that is to make the file belong to one app, and make this app expose some IPC or REST API, that the other app consumes.