0

I have a problem with a service based Database. I use a Service Based Database as a local database for my application. Everything is working correctly in my computer. But on some computers an error occurs.

What could be the reason?

_constr = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|StockPortfolio.mdf;Integrated Security=True";

The error:

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

Freeedy
  • 101
  • 3
  • 9
  • https://stackoverflow.com/questions/18060667/why-am-i-getting-cannot-connect-to-server-a-network-related-or-instance-speci/18060818#18060818 – kingdom445 Mar 07 '18 at 09:11
  • try using exact mdf file path in connection string "Server=(localdb)\v11.0;Integrated Security=true; AttachDbFileName=C:\MyFolder\MyData.mdf;" – Jophy job Mar 07 '18 at 10:37

1 Answers1

0

public class ComplexContext : DbContext { public DbSet Persons { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Database=SandboxComplex;Trusted_Connection=True;Integrated Security=true;"); } }