簡體   English   中英

添加遷移異常

[英]Add-migration Exeception

當我嘗試添加遷移時,出現此錯誤:

 PM> add-migration RestrictPromotionContentAndTitle
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 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. The system cannot find the file specified.
       at BrightInfo.Infrastructure.Settings.DbAudit.AuditDbContext..ctor(String connString)
       at BrightInfo.Infrastructure.Settings.BrightInfoContext..ctor(Boolean proxyCreationEnabled, Boolean lazyLoadingEnabled) in C:\Projects\BrightInfo\BrightInfo.Infrastructure.Settings\BrightInfoContext.cs:line 124
       at BrightInfo.Infrastructure.Settings.BrightInfoContext..ctor() in C:\Projects\BrightInfo\BrightInfo.Infrastructure.Settings\BrightInfoContext.cs:line 113
       --- End of inner exception stack trace ---
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Activator.CreateInstance(Type type)
       at System.Data.Entity.Infrastructure.DbContextInfo.<CreateActivator>b__0()
       at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo)
       at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType)
       at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext)
       at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
       at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
       at System.Data.Entity.Migrations.Design.ToolingFacade.GetPendingMigrationsRunner.RunCore()
       at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
    Exception has been thrown by the target of an invocation.

誰知道如何解決這個問題? 提前致謝。

PS:我忘了提到當我切換到包管理器控制台時,我收到此錯誤消息:

    Unable to find type [NuGet.PackageManager]. Make sure that the assembly that contains this type is loaded.
At C:\Projects\BrightInfo\packages\T4Scaffolding.Core.1.0.0\tools\init.ps1:4 char:5
+ if ([NuGet.PackageManager].Assembly.GetName().Version -lt 1.4)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (NuGet.PackageManager:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

有人知道如何解決嗎? 謝謝。

似乎您的項目中沒有正確的 dll 引用。

無法加載文件或程序集“Microsoft.Build.Framework,Version=15.1.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依賴項之一。 系統找不到指定的文件。 在...

如果您可以添加適當的dll並清理解決方案,重建解決方案然后再試一次,您應該可以成功執行。 如果進一步的錯誤仍然存​​在,請發布您找到的遷移詳細信息,以便更好地理解和幫助您。

HTH

我通過添加修復它:{ get; 設置; 到我的所有屬性

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM