在项目之间共享 SQL CE 4 数据库

发布于 2025-01-03 20:12:47 字数 234 浏览 2 评论 0原文

我在 VS2010 中有一个解决方案,其中包含两个 MVC 3 项目。这是两个不同的应用程序,必须作用于相同的数据,因此我需要在这些项目之间共享我的数据库。

我想使用 SQL CE 4,但由于它是内存中的本地数据库,我无法找到一种方法使其可用于两个不同的项目。到目前为止,我遇到的所有教程都建议您将 SDF 文件放在 App_Data 文件夹中,但这不适用于我的情况。

你们中有人成功做到了吗?

提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

漆黑的白昼 2025-01-10 20:12:47

虽然可以(阅读:硬链接)使 SQL CE 数据库可供两个应用程序使用,但这不是一个好主意,即使其中一个应用程序进行写入。为了明确这一点:N 个读取器工作,N 个读取器 + 1 个写入器不工作(读取错误、随机崩溃)。 N>1 的 N 个写入器会导致文件损坏。

典型的方法是使文件属于一个应用程序,并让该应用程序公开其他应用程序使用的一些 IPC 或 REST API。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文