简体   繁体   中英

C# Service Based Database error System.Data.SqlClient.SqlException (0x80131904)

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM