Sql Server Compact Edition 数据库部署策略

发布于 2024-08-02 13:05:27 字数 297 浏览 10 评论 0原文

我有一个关于使用我们的客户端应用程序部署 SQL Server CE 数据库的最合适方法的问题。我知道我们需要安装 SQL Server CE 先决条件等,所以这不是让它工作的问题。已经是这样了。

现在我们的方式是,我们只随应用程序发送 .mdf 文件的副本(不包含数据),该副本在安装过程中被复制到适当的位置。这工作得很好,但我想知道这是否是使用应用程序部署数据库的“正确”方法,或者数据库是否应该 a.) 在安装过程中生成(作为自定义安装操作),或者 b.)首次运行应用程序时生成。

任何想法或建议表示赞赏。我意识到这个问题可能没有可靠的答案。

I have a question about the most appropriate way to deploy a SQL Server CE database with our client application. I understand we need to install the SQL Server CE prerequisites etc., so this isn't a question about getting it to work. It already does.

Right now the way we have it is that we just ship a copy of the .mdf file (containing no data) with the application, which gets copied to the appropriate location during installation. This works perfectly fine, but I was wondering if this is the "correct" method of deploying a database with an application or if the database should be either a.) generated during the installation (as a custom install action), or b.) generated at the first run of the application.

Any thoughts or suggestions are appreciated. I realize there probably isn't a solid answer to this question.

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

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

发布评论

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

评论(2

春风十里 2024-08-09 13:05:27

这里讨论的是*.mdf文件,而不是如何确保SqlServerCE dll可用。

如何部署数据库应用程序很大程度上取决于以下问题:

数据库是针对每个用户的吗?

  • 如果不是应该是吗?
    • 在 Vista 及以上版本中,将数据库放在应用程序目录中是一个坏主意,因为修改文件时可能会触发 UAE 请求。
  • 如果是每个用户,那么实际上您必须为每个用户生成一个新的,因此必须为此运行一些代码,以便您可以轻松地使用以下任何方法。

如果没有,那么简单地包含一个初始文件就可以正常工作,并且是最简单的选择。

数据库一开始是空的吗(即,您可以“在代码中创建表结构,并且在任何地方都没有 *.mdf 文件作为其基础。

  • 这可以使您的测试更干净,但意味着您无法与“初始”数据库进行交互)像 SQL Sever 工具一样,
  • 如果初始状态只是模式或非常小,则在 dll 中嵌入“模板”将使您的部署更加灵活,并且意味着没有人可以通过删除/更改模板数据库来意外“破坏”模板数据库。 不更改 dll 的情况下

如果有重要数据,那么这几乎肯定会排除

更改数据库初始状态中的重要数据?

  • 可能希望在
  • 您 希望能够创建自定义部署而不生成新的构建

如果是这样,那么您可能希望该文件是单独的而不是作为嵌入式资源。

This is talking about the *.mdf file, not how to ensure that the SqlServerCE dll is available.

How you should deploy the database application is strongly dependent on the following questions:

Is the database per user?

  • If it isn't should it be?
    • Having the database in the applications directory is a bad idea on Vista onwards as it may trigger UAE requests when modifying the file.
  • If it is per user then realistically you must generate a new one for each user, so some code will have to run for this so you can just as easily use any of the following methods.

If not then simply including a single initial file will work fine and is the simplest option.

Is the database empty to start with (i.e.e you could 'create the table structure in code and have no *.mdf file anywhere to base it off.

  • This can make you testing cleaner but means you cannot interact with the 'initial' database with things like the SQL Sever tools.
  • If the initial state is either schema only or very small embedding the 'template' in the dll will make your deployment more flexible and will mean that no one can accidentally 'break' the template database by removing it/changing it by accident.

If there is significant data then this almost certainly precludes the embedded option.

Is there significant data in the initial state of the database that you may want to change without changing the dll?

  • Perhaps you want to customize it per client
  • Perhaps you want to be able to create a custom deployment without generating a new build.

If so then you will likely want the file separate rather than as an embedded resource.

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