0
votes

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.

1
try using exact mdf file path in connection string "Server=(localdb)\v11.0;Integrated Security=true; AttachDbFileName=C:\MyFolder\MyData.mdf;"Jophy job

1 Answers

0
votes

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;"); } }