1
resposta

Exceção Lançada

Pessoal, baixei o arquivo da aula anterior pois meu computador deu problema e tive que formatar.

tentei dar o camando Update-Database para criar os bancos para FilmesApi e funcionou normalmente. logo quando executo o mesmo comando para o UsuarioApi retorna esse erro, poderia me esclarer isso?

Build started...
Build succeeded.
C:\Program Files\dotnet\dotnet.exe exec --depsfile D:\estudos\alura-csharp3-Aula-5\FilmesApi\bin\Debug\net5.0\FilmesApi.deps.json --additionalprobingpath D:\Usuarios\antonione.lima\.nuget\packages --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig D:\estudos\alura-csharp3-Aula-5\FilmesApi\bin\Debug\net5.0\FilmesApi.runtimeconfig.json D:\Usuarios\antonione.lima\.nuget\packages\microsoft.entityframeworkcore.tools\5.0.5\tools\netcoreapp2.0\any\ef.dll database update --verbose --no-color --prefix-output --assembly D:\estudos\alura-csharp3-Aula-5\FilmesApi\bin\Debug\net5.0\UsuariosApi.dll --startup-assembly D:\estudos\alura-csharp3-Aula-5\FilmesApi\bin\Debug\net5.0\FilmesApi.dll --project-dir D:\estudos\alura-csharp3-Aula-5\UsuariosApi\ --language C# --working-dir D:\estudos\alura-csharp3-Aula-5 --root-namespace UsuariosApi
Using assembly 'UsuariosApi'.
Using startup assembly 'FilmesApi'.
Using application base 'D:\estudos\alura-csharp3-Aula-5\FilmesApi\bin\Debug\net5.0'.
Using working directory 'D:\estudos\alura-csharp3-Aula-5\FilmesApi'.
Using root namespace 'UsuariosApi'.
Using project directory 'D:\estudos\alura-csharp3-Aula-5\UsuariosApi\'.
Remaining arguments: .
Microsoft.EntityFrameworkCore.Design.OperationException: Could not load assembly 'UsuariosApi'. Ensure it is referenced by the startup project 'FilmesApi'.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'UsuariosApi, Culture=neutral, PublicKeyToken=null'. O sistema não pode encontrar o arquivo especificado.
File name: 'UsuariosApi, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.InternalLoad(ObjectHandleOnStack assemblyName, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
   at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, RuntimeAssembly requestingAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<get_Assembly>g__Create|14_0()
   --- End of inner exception stack trace ---
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<get_Assembly>g__Create|14_0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.get_Assembly()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.get_MigrationsOperations()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Could not load assembly 'UsuariosApi'. Ensure it is referenced by the startup project 'FilmesApi'.
1 resposta

Boa noite Antonione,

Como está a codificação do seu arquivo Startup.cs e da sua string de conexão no arquivo appsettings.json? Pode postar aqui?

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software