© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
14 replies
Populus

❔ Entity Framework - SqlException

Microsoft.Data.SqlClient.SqlException: '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. (provider: SNI_PN11, error: 50 - Local Database Runtime error occurred. Specified LocalDB instance name is invalid.
)'
Microsoft.Data.SqlClient.SqlException: '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. (provider: SNI_PN11, error: 50 - Local Database Runtime error occurred. Specified LocalDB instance name is invalid.
)'

internal static async Task Initialize(WebScraperContext context)
        {
            context.Database.Migrate();
        }
internal static async Task Initialize(WebScraperContext context)
        {
            context.Database.Migrate();
        }

using (var db = new WebScraperContext())
            {
                db.Database.EnsureCreated();
                db.SaveChanges();
            }
using (var db = new WebScraperContext())
            {
                db.Database.EnsureCreated();
                db.SaveChanges();
            }

public class WebScraperContext : DbContext
        {
            public DbSet<WebPage> WebPages { get; set; }

            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseSqlServer(@"Server=(localdb)\\MSSQLLocalDB;Database=my_localnetwork;Trusted_Connection=True;");
            }
        }
public class WebScraperContext : DbContext
        {
            public DbSet<WebPage> WebPages { get; set; }

            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseSqlServer(@"Server=(localdb)\\MSSQLLocalDB;Database=my_localnetwork;Trusted_Connection=True;");
            }
        }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Entity framework
C#CC# / help
14mo ago
❔ Entity Framework
C#CC# / help
3y ago
❔ Entity Framework
C#CC# / help
4y ago
Entity Framework Entity Saving
C#CC# / help
11mo ago