我想开始使用EF,并遵循Microsofts docs。一切正常,但是当我尝试创建初始迁移PM时会抛出异常。
Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly
'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable."
At C:\Users\Anton\.nuget\packages\entityframework\6.2.0\tools\EntityFramework.psm1:720 char:5
+ $domain.SetData('project', $project)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SerializationException
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName)
我在Google上搜索了很多,发现其他人拥有same problem。我在那里尝试了所有解决方案,尤其是那些包括设置启动项目的解决方案,但这似乎行不通。
例如,运行-StartupProjectName WebApplication1
只会引发一个错误,指出-StartupProjectName does not exist.
如果我下载了使用EF的示例项目,则迁移似乎可以正常进行。我也尝试过创建一个类库项目,并在那里进行了迁移,但是结果相同。