0
respostas

Quando publico a aplicação não conecta ao banco de dados

Quando faço o publish do app acontece o seguinte erro no log

fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
      An error occurred using the connection to database 'usuariodb' on server 'localhost'.
fail: Microsoft.EntityFrameworkCore.Query[10100]
      An exception occurred while iterating over the results of a query for context type 'UsuariosApi.Data.UserDbContext'.

quebrando a cabeça decidi atualizar o EntityFrameworkCore do MySql mas agora está voltando outro erro quando faço o Cadastro e Login

Esse é o erro que aparece no Cadastro, apesar de efetuar o cadastro no banco as vezes o email não é enviado, além de aparecer esse erro toda vez

fail: Microsoft.EntityFrameworkCore.Query[10100]
      An exception occurred while iterating over the results of a query for context type 'UsuarioApi.Data.UserDbContext'.

E aqui o meu maior problema, quando vou Logar com o usuário criado e validado, ele gera esse erro no server, está indicando um parametro como nulo mas eu to passando nome e password como fiz nos testes junto com o professor,

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMFB3GNP908M", Request id "0HMFB3GNP908M:00000003": An unhandled exception was thrown by the application.
      System.ArgumentNullException: Value cannot be null. (Parameter 'value')
         at System.Security.Claims.Claim..ctor(String type, String value, String valueType, String issuer, String originalIssuer, ClaimsIdentity subject, String propertyKey, String propertyValue)
         at System.Security.Claims.Claim..ctor(String type, String value)
         at UsuarioApi.Services.TokenService.CreateToken(IdentityUser`1 usuario, String role)
         at UsuarioApi.Services.LoginService.LogaUsuario(LoginRequest request)
         at UsuarioApi.Controllers.LoginController.LogaUsuario(LoginRequest request)
         at lambda_method135(Closure , Object , Object[] )
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

(DETALHE) nenhum desses erros acontece quando estou rodando a aplicação no VisualStudio só quando tento publicar e faço um POST.