Ensure that 782 version of a SQL Server Express LocalDB 2014 (.mdf) is respected when importing it into Visual Studio 2017

Aarón BD 65 Reputation points
2023-06-30T20:03:08.6433333+00:00

I have a database that I have generated in SQL Express 2014 (its version right now is 12.0.2000.8).

However, I have noticed that when adding it to Visual Studio 2017 as a local copy (to make it server independent), the version is altered and updated. The reason for this, to my understanding, is that Visual Studio has SQL Local Database tools and packages from 2016, not 2014, so it versions the file (I checked this by grabbing the .mdf from the solution directory after it was integrated into the application and uploading it back to SQL Server. It gives read error because it is a higher version).

This means that on deployment, even if the user installs the SQL Express LocalDB 2014 and .NET Framework 4 packages (I use this .NET to try to make the application compatible with Windows XP), the application cannot access the database and crashes.

This situation is further confirmed by the fact that, in previous attempts, it happened to me that the laptop where the application was developed was able to open the deployed application and when switching computers, it did not. This, which I did not understand at the time, was due to the fact that my computer does have the necessary packages to be able to read.

So, I have deleted all SQL packages that are later than 2014 and I have also deleted all traces in Visual Studio 2017. And here comes the problem, because when I try to add again the .mdf to the project I find that I can not do it if I do not install the same extensions that generated the problem.

In conclusion, I would need a way (I understand that this is a compatibility issue) to close the version of the database, so that it can be read and written, but that its version is not altered in any way. I imagine it is possible, but I have no idea how to do it. I could also use, if possible, Visual Studio 2017 to allow me to add the database using tools that do not alter the original.

Many thanks to anyone who can give me a hand with this issue.

Best regards

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,375 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,358 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,233 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 115.9K Reputation points MVP
    2023-06-30T21:11:08.4666667+00:00

    You can dowload SQL Server 2014 Express here: https://www.microsoft.com/en-us/download/details.aspx?id=42299 Download the ISO and find sqllocaldb.msi to install only local DB.

    When you create localdb instance, be sure to include version number, for instance:

    sqllocaldb create FOURTEEN 12
    

    Then refer to this instance as (localdb)\FOURTEEN.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.