gpt4 book ai didi

entity-framework - EF 6 基于代码的迁移异常 : Microsoft. VisualStudio.Data.Tools.Package 不可序列化?

转载 作者:行者123 更新时间:2023-12-03 07:11:00 25 4
gpt4 key购买 nike

我有这个配置

internal sealed class Configuration :DbMigrationsConfiguration<IAS.Models.ApplicationDbContext> {
public Configuration() {
AutomaticMigrationsEnabled = false;
ContextKey = "IAS.Models.ApplicationDbContext";
}

protected override void Seed( IAS.Models.ApplicationDbContext context ) {
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
context.Database.ExecuteSqlCommand(File.ReadAllText(baseDir + "\\MyInsertScriptsql"));
}
}

运行 upate-dataabase 时出现以下异常

Excepción al llamar a "SetData" con los argumentos "2": "El tipo 'Microsoft.VisualStudio.Data.Tools.Package.Internal.OAProject' del ensamblado 'Microsoft.VisualStudio.Data.Tools.Pa ckage, Version=11.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' no está marcado como serializable." En D:\Dev\Insuranse Advanced Services\IAS\packages\EntityFramework.6.0.0\tools\EntityFramework.psm1: 611 Carácter: 20 + $domain.SetData <<<< ('startUpProject', $startUpProject) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto. en System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion) en System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebProject(Project project) en System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory) en System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c_DisplayClass2.<.ctor>b_0() en System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) Referencia a objeto no establecida como instancia de un objeto.

最佳答案

问题已解决,我打开了文件..\packages\EntityFramework.6.0.0\tools\EntityFramework.psm 和第 611 行指出:

 $domain.SetData('startUpProject', $startUpProject)

在检查我的解决方案后,我发现启动项目已更改为数据库项目,纠正了此问题,问题就消失了。

关于entity-framework - EF 6 基于代码的迁移异常 : Microsoft. VisualStudio.Data.Tools.Package 不可序列化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21483671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com