I am using Visual Studio 2017 and SQL Server 2014. While attaching a database file to Visual Studio, I get this error:
After upgrading the file I used this connection string
<connectionStrings>
<add name="con"
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\binaaelmamorra.mdf;Integrated Security=True;Connect Timeout=30"/>
</connectionStrings>
It's working fine on my machine, but on the client machine, an error pops up saying
Cannot be opened because it is version 852. This server supports version 782 and earlier
Though I installed SQL Server 2016 local DB on the client side, I still can't get rid of it.
My second question is: what is the current instance of SQL Server to which the database file is not compatible?
It seems you have multiple instances of various versions of SQL Server on your machine.
For the "full-blown" versions (Express and up), you can check what version they are by looking at the SQL Server Configuration Manager:
For the "LocalDB" versions of SQL Server (developer-oriented versions), you can use the sqllocaldb
command line tool.
Get an overview of what you have on your machine using this command:
C:\> sqllocaldb i
MSSQLLocalDB
v11.0
Then, you can check the individual instances using the details command:
C:\> sqllocaldb i mssqllocaldb
Name: mssqllocaldb
Version: 13.1.4206.0
Shared name:
Owner: MSE-PC-02\Marc
Auto-create: Yes
State: Stopped
Last start time: 27.08.2017 12:24:45
Instance pipe name:
C:\> sqllocaldb i v11.0
Name: v11.0
Version: 11.0.3000.0
Shared name:
Owner: MSE-PC-02\Marc
Auto-create: Yes
State: Stopped
Last start time: 26.08.2017 15:41:18
Instance pipe name:
So this tells you that there are two instances of SQL Server LocalDB available - mssqllocaldb
is version 13.1 (SQL Server 2016), while the v11.0
instance is version 11.0 (SQL Server 2012).
So if you want to attach a .mdf
file to any one of those two instances, you just need to pick the right one in order to get it working with the version you want. And once you've "upgraded" a database file to a newer version of SQL Server (like 2016 - internal DB version 852), you can NEVER go back - there's no way to detach/attach, backup/restore or other ways to get those binary files to an older version of SQL Server. You would have to script out the structure (and possibly data) of your newer database file to .sql
files and run those on the older version.