我正在使用Service Fabric和Entity Framework 6.1.3。当我尝试使用“启用 - 迁移”启用迁移时出现错误:
Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly
'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable."
At C:\repos\Gsa.Pops.Bookings\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:720 char:5
+ $domain.SetData('startUpProject', $startUpProject)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SerializationException
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebProject(Project project)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object reference not set to an instance of an object.
我认为EF无法找到连接字符串,因为启动项目是Service Fabric应用程序(因此没有web.config,而是ApplicationManifest.xml和多个环境配置)
有任何线索吗? 谢谢, 阿尔贝托
答案 0 :(得分:1)
您可以将连接字符串存储在Azure中的KeyVault中,然后从那里获取基础结构项目。
答案 1 :(得分:1)
请使用以下命令启用迁移, 启用 - 迁移-EnableAutomaticMigrations -ProjectName&lt;迁移文件夹将包含的项目名称&gt; -StartUpProjectName&lt;连接字符串存在的项目名称&gt;