1

When I run my web application using asp.net mvc, I get this error :

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

My 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>

Connection to the database

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

Have I installed SqlLOcalDB? Can you help me please?

1

1 Answer 1

0

When all else fails and you don't care about data loss, delete and recreate your LocalDB\YourDbName database! At the command prompt

sqllocaldb delete YourDbName sqllocaldb create YourDbName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.