Bom dia, Quando fiz o download do projeto da API disponibilizada ao executar esta dando erro de conexão com o bd. Como resolver? Link para download https://caelum-online-public.s3.amazonaws.com/864-asp-net-core-web-api/01/Alura.WebAPI.ProjetoInicial.zip
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace Alura.ListaLeitura.Seguranca
{
public class AuthDbContext : IdentityDbContext<Usuario>
{
public AuthDbContext(DbContextOptions<AuthDbContext> options)
: base(options)
{
//irá criar o banco e a estrutura de tabelas necessárias
this.Database.EnsureCreated(); **(X)**
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ApplyConfiguration<Usuario>(new UsuarioConfiguration());
}
}
}
Informações sobre o erro.
System.Data.SqlClient.SqlException HResult=0x80131904 Message=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: 50 - Local Database Runtime error occurred. Erro durante a inicialização da instância de LocalDB: falha ao inicializar o processo do SQL Server. ) Source=Core .Net SqlClient Data Provider StackTrace: at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) ..... Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Exists() at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreated() at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated() at Alura.ListaLeitura.Seguranca.AuthDbContext..ctor(DbContextOptions`1 options) in C:\Users\aff-o\source\repos\Alura.WebAPI\Alura.WebAPI.DAL.Usuarios\AuthDbContext.cs:line 12
Exceção interna 1: Win32Exception: Unknown error (0x89c5010a)