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

Commands: show better error when executing on a UWP class library #5878

Closed
davesmits opened this issue Jun 27, 2016 · 9 comments

Comments

@davesmits
Copy link

commented Jun 27, 2016

One of my apps i was trying to upgrade from RC1 to RTM i hit a issue with a refence not set to an instance error when running "Add-Migration". I start to make a new project with the same structure to figure out what is going on, but before i was able to come to that state hitting another issue:

When doing "Add-Migration InitialDB" I get this exception:
Add-Migration : Exception calling "CreateInstanceAndUnwrap" with "8" argument(s): "Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its
dependencies. The system cannot find the file specified."
At line:1 char:1

  • Add-Migration initialdb
  • - CategoryInfo          : NotSpecified: (:) [Add-Migration], MethodInvocationException
    - FullyQualifiedErrorId : FileNotFoundException,Add-Migration
    
    

I added a repro project. You need to set the EFTest.Model as startup project and default project
EFTest.zip

@natemcmaster natemcmaster changed the title Add-Migration results in Exception calling "CreateInstanceAndUnwrap" with "8" argument(s): UWP Commands: unhelpful error when executing on a UWP class library Jun 27, 2016

@natemcmaster

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2016

Confirmed this is an issue. It happens when a UWP class library project is marked as the "startup" project. MSBuild for UWP csproj does not copy dependencies into build target dir (bin/) so the powershell commands cannot execute.

Workaround

Set the UWP app as the Startup project (right click on project > Set as StartUp project) or use the -StartupProject option in PMC.

@rowanmiller rowanmiller added this to the 1.1.0 milestone Jun 29, 2016

@rowanmiller rowanmiller added the pri0 label Jun 29, 2016

@SamuelLioult

This comment has been minimized.

Copy link

commented Jun 30, 2016

@natemcmaster this workaround doesn't work for me. I think it is because my data part is in this library. So when I try to run the command line with the UWP app as startup project, I get this error:

Cannot execute this command because Microsoft.EntityFrameworkCore.Tools is not installed in the startup project 'UWPProject'.

EDIT: it works adding an app.config file as it is suggested here #5471

@natemcmaster

This comment has been minimized.

Copy link
Contributor

commented Jun 30, 2016

@SamuelLioult you will need to install Microsoft.EntityFrameworkCore.Tools into the startup project, not the class library project.

@SamuelLioult

This comment has been minimized.

Copy link

commented Jun 30, 2016

@natemcmaster I tried it but I get the error reported here #5471 but it works with the app.config as in the proposed workaround.

@rowanmiller rowanmiller removed the pri0 label Jul 6, 2016

natemcmaster pushed a commit to natemcmaster/EntityFrameworkCore that referenced this issue Jul 8, 2016
natemcmaster pushed a commit to natemcmaster/EntityFrameworkCore that referenced this issue Jul 8, 2016
natemcmaster pushed a commit to natemcmaster/EntityFrameworkCore that referenced this issue Jul 8, 2016
Nate McMaster

@natemcmaster natemcmaster changed the title UWP Commands: unhelpful error when executing on a UWP class library Commands: show better error when executing on a UWP class library Jul 8, 2016

@bartlannoeye

This comment has been minimized.

Copy link

commented Oct 17, 2016

For future reference: I had the reported issue while trying to add migrations with the AnyCPU configuration selected (which happened to be default on opening the project and doesn't build the UWP app). Swithing to x86 fixed it.

@bricelam

This comment has been minimized.

Copy link
Member

commented Oct 17, 2016

@bartlannoeye In the next release (1.0.0-preview3), you'll be able to have any of AnyCPU, x64, or x86 selected.

@yehe01

This comment has been minimized.

Copy link

commented Oct 27, 2016

Hi,
I am having this issue on a console application from this tutorial. The issue only exists on EntityFrameworkCore but not EntityFramewokr6.x. BTW, I am developing in a Windows 10 virtual machine with the latest tool installed. Also, I did set the console project as the startup project.

capture

My package.json

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net452" />
  <package id="Microsoft.AspNetCore.Hosting.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.AspNetCore.Http.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.AspNetCore.Http.Features" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore" version="1.0.1" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.Design" version="1.0.1" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.Relational" version="1.0.1" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.Relational.Design" version="1.0.1" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.SqlServer" version="1.0.1" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.SqlServer.Design" version="1.0.1" targetFramework="net452" />
  <package id="Microsoft.EntityFrameworkCore.Tools" version="1.0.0-preview3-final" targetFramework="net452" developmentDependency="true" />
  <package id="Microsoft.Extensions.Caching.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Caching.Memory" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Configuration.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.FileProviders.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Logging" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Options" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.Primitives" version="1.0.0" targetFramework="net452" />
  <package id="Remotion.Linq" version="2.1.1" targetFramework="net452" />
  <package id="System.Collections" version="4.0.11" targetFramework="net452" />
  <package id="System.Collections.Concurrent" version="4.0.12" targetFramework="net452" />
  <package id="System.Collections.Immutable" version="1.2.0" targetFramework="net452" />
  <package id="System.ComponentModel" version="4.0.1" targetFramework="net452" />
  <package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net452" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.0.0" targetFramework="net452" />
  <package id="System.Globalization" version="4.0.11" targetFramework="net452" />
  <package id="System.Interactive.Async" version="3.0.0" targetFramework="net452" />
  <package id="System.IO" version="4.1.0" targetFramework="net452" />
  <package id="System.Linq" version="4.1.0" targetFramework="net452" />
  <package id="System.Linq.Expressions" version="4.1.0" targetFramework="net452" />
  <package id="System.Linq.Queryable" version="4.0.1" targetFramework="net452" />
  <package id="System.ObjectModel" version="4.0.12" targetFramework="net452" />
  <package id="System.Reflection" version="4.1.0" targetFramework="net452" />
  <package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net452" />
  <package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net452" />
  <package id="System.Runtime" version="4.1.0" targetFramework="net452" />
  <package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net452" />
  <package id="System.Runtime.InteropServices" version="4.1.0" targetFramework="net452" />
  <package id="System.Text.Encodings.Web" version="4.0.0" targetFramework="net452" />
  <package id="System.Threading" version="4.0.11" targetFramework="net452" />
  <package id="System.Threading.Tasks" version="4.0.11" targetFramework="net452" />
</packages>
@yehe01

This comment has been minimized.

Copy link

commented Oct 27, 2016

Issue solved by creating a clean project. Also, the tutorial doesn't mention to install Microsoft.EntityFrameworkCore.Design, but it's apparently needed.

@bartlannoeye

This comment has been minimized.

Copy link

commented Nov 28, 2016

And this error is back on UWP with the latest tools (1.1.0-preview4-final). Our client's patient is getting really thin by the continued delays caused by EF Core. It's sad to see these tools are so fragile and lack a correct guide to follow.

Returned to our old configuration to re-enable migrations:

"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.