Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration commands crash when running against an SDK-based csproj #230

Closed
HellBrick opened this issue Mar 24, 2017 · 13 comments
Closed

Migration commands crash when running against an SDK-based csproj #230

HellBrick opened this issue Mar 24, 2017 · 13 comments

Comments

@HellBrick
Copy link

I've encountered this problem when trying to convert a project to the new SDK-based csproj. It had worked fine until I tried to add a new migration, which crashed with the following error:

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, Publ
icKeyToken=b03f5f7f11d50a3a' is not marked as serializable."
At C:\Users\HellBrick\.nuget\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.GetPropertyValue[T](Project project, String propertyName)
   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.

You can easily reproduce this with a new project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="EntityFramework" Version="6.1.3" />
  </ItemGroup>
</Project>
using System.Data.Entity;
namespace EntityFrameworkNewCsprojTest
{
	public class SomeEntity
	{
		public int ID { get; set; }
		public int Name { get; set; }
	}

	public class TestContext : DbContext
	{
		public DbSet<SomeEntity> SomeEntities { get; set; }
	}

	internal class Program
	{
		static void Main( string[] args ) {}
	}
}

Running Enable-Migrations against it will cause the same error.

This is a very unpleasant blocker for us, is there any way to at least work around this problem?

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 24, 2017

Use a standard "Classic" class library?

@HellBrick
Copy link
Author

HellBrick commented Mar 24, 2017

That's what we're doing today =) The old csproj format works, but the whole point of this issue is to figure out how to migrate to the new csproj format while keep using EF 6.

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 24, 2017

You will be entering a world of pain, suggest you wait for a new EF version (ie 6.3) with support for new project format NuGet/Home#4876

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 24, 2017

I have logged #231

@HellBrick
Copy link
Author

"World of pain" is a relative term, the old csproj isn't that pleasant to deal with either ;) If this can't be done without some substantial engineering work in the EF codebase, then there's no other choice but to wait for the update. However, if it's possible to make migrations work via some manual adjustments to project file/app.config/migration script/whatever, then it might just be worth it.

@ajcvickers
Copy link
Member

Closing this as a dupe of #231, which we are investigating.

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 29, 2017

@ajcvickers Think you forgot to actually close?

@ajcvickers
Copy link
Member

@ErikEJ Thanks. You are our process bot. 😉

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 29, 2017

Sorry! 😄

@ajcvickers
Copy link
Member

@ErikEJ Don't apologize. It is much appreciated. 😸

@divega
Copy link
Contributor

divega commented Jul 11, 2017

@DeshmukhParag could you please explain the intent of your previous comment? Is there something not working according to your expectations?

@smitpatel
Copy link
Member

@bricelam - In above image, EFCore\Enable-Migrations says to use EF\Update-Database for EF6. which would be incorrect. Can you verify, we are doing correct thing?

@bricelam
Copy link
Contributor

bricelam commented Jul 11, 2017

Ha, nice. It's a bug. dotnet/efcore#9150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants