Reputation: 861
I wanted to get started using EF and followed Microsofts docs. Everything builds fine but when I try to create the initial migration PM throws an exception.
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)
I have googled a lot and found other people having the same problem. I have tried all the solutions there, especially the ones including setting the startup project but that does not seem to work.
For example running -StartupProjectName WebApplication1
just throws an error saying that -StartupProjectName does not exist.
If I download an example project that uses EF however, migrations seem to work. I have also tried creating a class lib project and done the migrations there but it has the same result.
Upvotes: 2
Views: 2728
Reputation: 861
As @Ivan Stoev pointed out, I was using the wrong EF version. Here is a short article explaining the difference between EF and EF Core.
Upvotes: 4