问题
My configuration is as follows:
Server with Z: mapped to d:\something
Client with Z: mapped to \\server\ A LocalDB MDF (and the whole application) located at Z:
Either computer alone is OK, but doesn't work simultaneously. I get an exception saying System.Data.SqlClient.SqlException 0x80131904 Cannot open database z:\xxx\xxx.mdf requested by the login. the login failed.
回答1:
This cannot be done. SQL requires than physical file attached to the database should be opened exclusively by the engine.
Solved by installing SQLEXPRESS which supports remote connections.
回答2:
This can be done. But it's not easy (did this with SQL 2016 localdb).
- create the database locally. The database will be created in C:\Users\ eg
c:\Users\eric\database.mdf
- Close SSMS (or disconnect from the object explorer)
- from a command prompt:
MSSQLLocalDB stop
- move the database.mdf & database_log.ldf to a network drive (eg s:\sql\database.mdf).
create symbolic links from the original location to new location. From a command prompt:
mklink c:\Users\eric\database.mdf s:\sql\database.mdf mklink c:\Users\eric\database_log.ldf s:\sql\database_log.ldf
MSSQLLocalDB start
来源:https://stackoverflow.com/questions/12107158/concurrent-use-of-localdb-on-a-network-drives