开发者

How to save SQL server database with my wpf project files on a disc

开发者 https://www.devze.com 2023-03-02 13:21 出处:网络
this may seem like a silly question but how do i save my database along with my c# project to another location like a cd or penDrive?

this may seem like a silly question but how do i save my database along with my c# project to another location like a cd or penDrive?

It is my first time using Visual Studio. I have created a project that connects and uses the SQL server express. Now i need to save all my files onto a disc to be given to some开发者_StackOverflowone to test my project, but i do not know how to save a database to it too?

Can anyone help? THanks, Emack.


Check out SQLite. It's a local file that will deploy with your WPF application by simply including the dll for it in the project dependencies appropriately. It has a pretty nice entity framework provider for it as well. You also get the advantage that you won't have to have your client users instal a sql server or anything crazy like that. I used it for my latest WPF app, and it has been fabulous.


SQL Server database files cannot just be copied like other files - they're under control of your SQL Server instance.

When you want to deploy an existing database, you have two options:

  • create SQL scripts to create and populate your database and ship those with your install package, and run them at install time

or:

  • detach the SQL Server files from your SQL Server instance, then copy those files (.mdf/.ndf/*.ldf) and on the target system, re-attach the database to the server again (or you could do a backup/restore cycle - works similarly)
0

精彩评论

暂无评论...
验证码 换一张
取 消