[英]How to Deploy Database in Application Installtion
I have an application which uses Sql Server Express Edition to store data. 我有一个使用Sql Server Express Edition存储数据的应用程序。 I have a database with 8-10 tables in it.
我有一个带有8-10个表的数据库。 I have mdf and ldf file with me.
我有mdf和ldf文件。 Now i want to install my application in some other computer, then how to deploy my database with my installation files (assuming the other computer already have Sql Server with them).
现在,我想在其他计算机上安装我的应用程序,然后如何使用我的安装文件部署数据库(假设另一台计算机已经具有Sql Server)。 Can i use my mdf and ldf files, or i need to create my database and tables again programatically during installation of my Application.
我可以使用我的mdf和ldf文件,还是需要在安装应用程序时以编程方式再次创建数据库和表。
I am a newbie, please guide me. 我是新手,请引导我。 I am using .Net framework 4.0 and Visual Studio Professional Edition.
我正在使用.Net Framework 4.0和Visual Studio Professional Edition。
SQL Server Express runs out-of-process, so your application does not control the data files. SQL Server Express进程外运行,因此您的应用程序无法控制数据文件。 You have to submit your application data to SQL Server via data statements, replication, or whatever, and SQL Server gets to decide what to do with them.
您必须通过数据语句,复制或其他方式将应用程序数据提交到SQL Server,然后SQL Server可以决定如何处理它们。
You may be able to submit an .mdf directly to SQLS Express via an AttachDBFilename
connection string, I have not tried this. 您可能可以通过
AttachDBFilename
连接字符串直接将.mdf提交到SQLS Express,但我没有尝试过。
If you used an embedded database like SQL Server Compact you would be able to include the data along with your application. 如果使用嵌入式数据库(如SQL Server Compact),则可以将数据与应用程序一起包括在内。 Whether this is a better solution depends on what else you are doing with your database.
这是否是更好的解决方案,取决于您对数据库所做的其他事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.