Entity Framework Update Database

5

When I run the command Update-Database I get the following error

  

Could not load file or assembly 'Microsoft.Build.Framework,   Version = 15.1.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a 'or   one of its dependencies.

All the output of the command

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
No pending explicit migrations.
Running Seed method.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.
File name: 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Syns.Common.SynsLegadoContext.Auditar()
   at Syns.Common.SynsLegadoContext.SaveChangesAsync(CancellationToken cancellationToken) in D:\Projetos\Syns\Syns\Syns\SynsLegadoContext.cs:line 38
   at System.Data.Entity.DbContext.SaveChangesAsync()
   at Microsoft.AspNet.Identity.EntityFramework.UserStore'6.<SaveChanges>d__5a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.Identity.EntityFramework.UserStore'6.<UpdateAsync>d__1c.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.Identity.UserManager'2.<UpdateAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNet.Identity.UserManager'2.<RemovePasswordAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.Identity.AsyncHelper.RunSync[TResult](Func'1 func)
   at Microsoft.AspNet.Identity.UserManagerExtensions.RemovePassword[TUser,TKey](UserManager'2 manager, TKey userId)
   at Syns.Common.Migrations.Configuration.AlterarSenhaUsuarios() in D:\Projetos\Syns\Syns\Syns\Migrations\Configuration.cs:line 265
   at Syns.Common.Migrations.Configuration.Seed(SynsLegadoContext context) in D:\Projetos\Syns\Syns\Syns\Migrations\Configuration.cs:line 41
   at System.Data.Entity.Migrations.DbMigrationsConfiguration'1.OnSeed(DbContext context)
   at System.Data.Entity.Migrations.DbMigrator.SeedDatabase()
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.SeedDatabase()
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable'1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable'1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClasse.<Update>b__d()
   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

AVI: o log de associações de assembly está desativado.
Para ativar o log de  falhas de assembly, defina o valor do Registro [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) como 1.
Observação: há alguma penalidade para o desempenho associada ao log de falha de associação de assembly.
Para desativar esse recurso, remova o valor do Registro [HKLM\Software\Microsoft\Fusion!EnableLog].

Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.
    
asked by anonymous 14.12.2017 / 12:03

1 answer

4

After a few weeks struggling with this problem, I made some discoveries.

The first is that the path to the% dll Microsoft.Build.Framework in the devenv.exe.config file that is in the C:\Program Files (x86)\Microsoft Visual Studio17\Community\Common7\IDE\ folder is set as ..\..\MSBuild.0\Bin\Microsoft.Build.Framework.dll , which would refer to the folder C:\Program Files (x86)\Microsoft Visual Studio17\Community , I soon thought that changing all occurrences where ..\..\ to the full path sanaria. But this solution is affected when I update VS and for some other reason, which I have not figured out yet, VS changes this file.

The last solution I applied was to register the dlls using gacutil

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.Framework.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.Engine.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.Conversion.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.Tasks.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.0\Bin\Microsoft.Build.Utilities.Core.dll"

Before running these commands, you have to close Visual Studio and open the Developer Command Prompt for VS 2017 as Administrator.

This has been my solution for the moment.

    
10.01.2018 / 11:51