简体   繁体   中英

how to C# project public with .mdf file

How can I publish a C# project with a .mdf database? I would like that it can be setup easily and need not install a sqlserver. Do I need to change to .sdf? The Project only uses it in local.

.MDF files are SqlServer main data files, i doubt you can use them without SqlServer installed, as for SqlServer Compact Databases (.sdf) they can be used like you want but converting from one to another isnt just a matter of changing the extension, they are db with different formats.

You would need to create a new .sdf and replicate the schema you have in your .mdf and then copy your data somehow, also you would need to adapt your project since access to data on an .sdf is different than an .mdf not to mention .sdf doesn't support all the things that .mdf does

Why don't you simply deploy your application with .mdf file along with a SQL Local DB installation on user machine who doesn't havd Visual Studio installed?

Make sure you install proper LocalDB. ie x86 version of installer on 32 bit and x64 installer for 64 bit machine. There is two different installer for both achitechture.

Sql Server is not installed as part of Windows installation, so you cannot use an *.mdf file in your app unless Sql Server has been installed and you have appropriate permissions for it.

It is possible to distribute either Sql Server Express Edition or Sql Server Compact Edition (recommended) with your app.

MDF files are part of SQL server databases. Without SQL Server (or Express), you can't use them.

If you need an embedable database, SQLite is a good option. Firefox also ships with an embedded SQLite instance, so it's a good/proven option. SQLite also integrates well with ADO.NET; I wrote an article on that here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM