0

I am facing a very weird situation where by my company wants me to use SQL Server Express. But the issue is I need to use the same SQL Server Express database for connection by different projects.

How do I do that?

I am using Entity Framework and C#.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
vini
  • 4,657
  • 24
  • 82
  • 170

2 Answers2

2

You'll need to copy your .mdf from your App_Data folder into SQL Server Express's data folder, attach the database to your Express instance, and then change your connection string to reference the instance instead of the location of the .mdf.

This answer to a similar question gives detailed, step-by-step instructions for this process.

Community
  • 1
  • 1
Michael Fredrickson
  • 36,839
  • 5
  • 92
  • 109
1

It seems you are trying to attach local database file with AttachDbFilename= option in the connection string. But you can't simultaneously attach the same .mdf on a local drive with several concurrent applications (like you can do with MS Access).

Rather just install SQL Server Express on a central computer and open it up for remote TCIP/IP access, attach your database to it and change the connection string to an IP / instance one.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
k2ly2n
  • 31
  • 4