Entity Framework Update Database

Asked

Viewed 873 times

6

When executing the command Update-Database I have 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.

The whole output of 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.
  • Check your config for Microsoft.Build.Framework if you haven’t been using it or haven’t installed it, delete the line that contains it from web.config. if you don’t install it in your project.

  • I have no reference to Microsoft.Build.Framework on my web.config

  • Weird, somewhere he’s trying to access this dll. has an answer ... https://stackoverflow.com/a/43498190/2740371

  • Closing and opening VS is not very productive

  • 1

    What I did is in this answer https://stackoverflow.com/a/44723132/2221388 so far has solved the problem for me.

  • I’ve seen a setting to makes it kind of standard, but now I can’t remember what it was like.

  • 1

    Because it is, every new update of VS it puts back the path of dll with ....

Show 2 more comments

1 answer

5


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 archive devenv.exe.config that’s in the folder C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ is defined as follows: ..\..\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll which would link to the folder C:\Program Files (x86)\Microsoft Visual Studio\2017\Community, soon I thought that changing all occurrences where it has ..\..\ for the complete path would heal. But this solution is affected when I update VS and for some other reason, which I haven’t discovered yet, VS changes this file.

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

gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Engine.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Conversion.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.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 now.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.