etablieren Wenn ich meine Web-Anwendung mit asp.net Mvc laufen, bekomme ich diesen Fehler:Es kann keine Verbindung zu SQL Server LocalDB
Server Error in '/' Application.
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
error source :
var result = await UserManager.CreateAsync(user, model.Password);
Mein web.config
:
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication23-20160409124123.mdf;Initial Catalog=aspnet-WebApplication23-20160409124123;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Anschluss an die Datenbank
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
dans CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
Habe ich SqlLOcalDB installiert? Kannst du mir bitte helfen?
Werfen Sie einen Blick auf die Antwort von @Nawfal in diesem Beitrag: http://StackOverflow.com/Questions/10540438/what-is-the-connection-string-for-localdb-for-version-11-- he umfasst das Überprüfen der Installation, das Überprüfen, ob eine LOCALDB-Instanz vorhanden ist, und das Abrufen der Verbindungszeichenfolge. –