I am creating a C # DataAccess class library for an MVC application. Inside the class library, I use EntityFramework and ASP.NET Identity.
When I try to run Database Update or Add-Migration in the class library, I get an error.
Error 26:A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
My UserAccount class derived from IdentityUser is below:
public class UserAccount : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
public virtual Address Address { get; set; }
public virtual PaymentDetail PaymentDetail { get; set; }
public virtual MediaResource ProfilePicture { get; set; }
public virtual ICollection<Conversation> Conversations { get; set; }
}
An implementation of my context class uses this constructor:
public class LouderContext : IdentityDbContext<UserAccount>
{
public LouderContext("DefaultConnection") { }
The contents of my App.config file are as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" providerName="System.Data.SqlClient"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v12.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Things I tried:
- Change factory connection parameter to
mssqllocaldbor v12.0fromv11.0 - Restoring the installation of my visual studio
- SQL Server connectionstring App.config
(localdb)\MSSQLLocalDB SSMS . LocalDb MVC, , . ? - ?