0

I'm trying to connect to a local db, with both an .mdf file and a regular connection string, in .NET Core. This has to work on other computers I send it to (my teacher has to be able to open it).

When I run

dotnet ef database update

or

Database.Migrate() 

I get this error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SNI_PN11, error: 26 - Error Locating Server/Instance Specified)'

Or this error, for my .mdf:

The database 'C:\USERS\SAM BA\DOCUMENTS\DINDER\DINDER\DATA\DINDER.MDF' cannot be opened because it is version 904. This server supports version 852 and earlier. A downgrade path is not supported. Could not open new database 'C:\USERS\SAM BA\DOCUMENTS\DINDER\DINDER\DATA\DINDER.MDF'. CREATE DATABASE is aborted. An attempt to attach an auto-named database for file C:\Users\Sam ba\Documents\Dinder\Dinder\Data\Dinder.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.'

What I've tried:

  • All protocols enabled in SQL Server Configuration Manager
  • All ports that SQL Server is listening to are enabled in Windows firewall
  • All services are running, both in services.msc and Configuration Manager, and have been restarted a couple of times
  • Tried multiple different connection strings (putting \\SQLEXPRESS at the start of one of them seems to work for others in my group but not for me)

This is the latest I've tried:

"DinderDB": "Server=(localdb)\\mssqllocaldb;AttachDBFilename=%CONTENTROOTPATH%\\Data\\Dinder.mdf;Trusted_Connection=true;MultipleActiveResultSets=true",
"IdentityDB": "Server=.\\SQLEXPRESS\\mssqllocaldb;Database=aspnet-Dinder-058AB7F2-0AF1-4B50-9DC0-9B2E9E418C15;Trusted_Connection=True;MultipleActiveResultSets=true"
  • (localdb)\\MSSQLLocalDB and DESKTOP-xxxxx both set to allow remote connections in SQL Server Management Studio
  • .mdf file is set to allow everything in the security tab

And two more things I've noticed, if at all relevant:

  • (localdb)\\MSSQLLocalDB has a blue icon next to it in Management Studio
  • (localdb)\\MSSQLLocalDB and DESKTOP-xxxxx are running different SQL Server versions (13 and 15)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 4
    *"The database 'C:\USERS\SAM BA\DOCUMENTS\DINDER\DINDER\DATA\DINDER.MDF' cannot be opened because it is version 904. This server supports version 852 and earlier."* The error is literally telling you the problem here. Databases from newer versions of SQL Server cannot be added/restored on older versions. – Thom A Mar 13 '21 at 13:51
  • what do I do about that, reinstall SQL Server? – hedonicadapter Mar 13 '21 at 19:01
  • You'll need to install a version that supports the database. That may well mean purchasing licences too. – Thom A Mar 13 '21 at 19:47
  • 1
    By the way https://stackoverflow.com/questions/11178720/whats-the-issue-with-attachdbfilename – Charlieface Mar 13 '21 at 21:43

0 Answers0