客户端 PC 上的 LocalDB 部署

我对这个新版本的 SQL Server Express 非常感兴趣.

I am very intrigued by this new version of SQL Server Express.

(对我而言)不清楚安装程序应该做什么来部署使用 LocalDB 的应用程序.

It's not clear (to me) what a setup program should do to deploy an application that use a LocalDB.

是否需要在客户端 PC 上安装 SQL Server Express 然后附加 MDF 文件?

Is it required to install SQL Server Express on the client PC and then attach the MDF file?

或者它只需要运行 LocalDB.msi 并且它像 SQL Server Compact 一样作为独立文件工作?

Or it's only required to run the LocalDB.msi and it works as a standalone file like SQL Server Compact?

推荐答案

使用LocalDB不需要安装SQL Server Express,LocalDB就是SQL Server Express,安装更简单.

You don't need to install SQL Server Express to use LocalDB, as LocalDB is SQL Server Express, just easier to install.

安装 LocalDB 后,您可以使用连接字符串的 AttachDbFileName 属性打开"一个 MDF 文件.请记住,同一文件在任何给定时间只能由单个 LocalDB 实例(单个 Windows 登录)打开,因此这不是数据共享功能.

Once LocalDB is installed you can use AttachDbFileName property of the connection string to "open" an MDF file. Keep in mind that the same file can only be opened by a single LocalDB instance (single Windows login) at any given time, so this is not a data-sharing feature.

更新:如果您的应用程序使用 .NET,请确保安装 .NET 4.0.2 或更新版本,如 此处提到.最初的 .NET 4 不理解 LocalDB 连接字符串,因为它早于 LocalDB 发布.

Update: If your application is using .NET, make sure to install .NET 4.0.2 or newer, as mentioned here. The original .NET 4 doesn't understand LocalDB connection strings, as it shipped long before LocalDB.

相关文章