That's not how SQL Server works. You don't copy the
.mdf
file to the client computer; you attach it to an existing instance of SQL Server, and have the client connect to that instance.
If you're using the
AttachDBFileName
option, the user will need to have a copy of SQL Server Express installed on their computer. You will also find that the database will
not be shared between different instances of your application, or between different users or different computers.
Bad habits : Using AttachDBFileName - SQL SentrySQL Sentry Team Blog[
^]
Also note that this feature will be removed in a future version:
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
If you want a simple file-based database, you could use
LocalDB[
^], but that still needs to be installed. Alternatively, you could use SQL CE, but that has far fewer features.
SQL Express v LocalDB v SQL Compact Edition – Jerry Nixon[
^]