Can't create a migration with EF Core 1.1

asp.net-core entity-framework-core

Question

I've spent two whole days trying to create an initial migration for the database of my project. This is so fustrating. Each preview version of the docs points towards different directions, and there're a lot of unclosed issues flying arround for a while.

My project is an AspNetCore application running on the full framework (net462) although I think I've tryed every combination of preview versions, even the workarounds proposed on this issue: EF Tools 1.1.0-preview4 Unrecognized option '--config' or in this one: https://github.com/aspnet/EntityFramework/issues/7083 but neither work.

This is an abstract of my project.json with the relevant parts:

{
    "version": "1.0.0-*",
    "buildOptions": {
        "platform": "x86",
        "debugType": "full",
        "preserveCompilationContext": true,
        "emitEntryPoint": true
     },

     "dependencies": {
        ....
        "Microsoft.EntityFrameworkCore": "1.1.0",
        "Microsoft.EntityFrameworkCore.Design": "1.1.0",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
        "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
        ....
       },

      "tools": {
         "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
         "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"
       },

       "frameworks": {
            "net462": {
            }
        },

    ...
}

In my case the proposed workarounds don't work, neither using the nightly builds nor downgrading the tools to 1.0.0-preview3.

If I use the 1.1.0-preview4-final version of the tools I hit this error:

Unrecognized option --config

If I use the nightly builds I get this one, wich is somehow absurd, as my app has only one project and is not a dll (it has also emitEntryPoint:true set)

Could not load assembly 'Sales'. Ensure it is referenced by the startup project 'Sales'

But this is my favourite one, when I downgrade to the 1.0.0-preview3-final of the tools I get this surrealistic one:

error: Package Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0-preview3-final is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0-preview3-final supports: netcoreapp1.0 (.NETCoreApp,Version=v1.0)

I had to read it five times to get sure that in the second sentence was telling just the opposite of the first one... It seems a joke!

Furthermore, commands are not working on the PMC anymore, no matter wich version of the tools I install, no matter if I restore the packages and if I restart the computer...

I'm getting crazy with so many versions of everything and I only want to create a migration, it doesn't matter wich version of the tools I have to use... Is there a valid configuration nowadays or am I trying something imposible? Has anybody been able to create migrations within an asp.net core application targeting the full .net framework (net462) with ANY version of the ef tooling?

If so, HOW?

EDIT:

After targeting the project to .netcoreapp1.0 and removing the incompatible references now I hit this error:

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\1.0.1'

What's happening here??? I'm really tired of .net Core, and it's still in it's first version. I've suffered a lot of issues like this while it was in beta, but now things are supposed to be stable... They have changed twenty times everything that can be changed, APIs, assembly names, namespaces, package names, conventions... Now let's wait for the preview5, 6 or 25 of the tooling and maybe by the year 2035 EF Core will have appropiate tools and procedures, meanwhile I damn a million time my decission of betting for this technology!

EDIT 2:

As per comments global.json may be relevant:

{
  "projects": [ "src", "test" ],
    "sdk": {
        "version": "1.0.0-preview2-1-003177"
    }
}

and to add that the 1.0.0-preview2-1-003177 folder exists and is the only one in C:\Program Files (x86)\dotnet\sdk\ and C:\Program Files\dotnet\sdk\

1
2
12/12/2016 3:27:03 PM

Accepted Answer

I hate to answer my own question, but I suppose that not too much people will go into this alley... So for those who are struggling with a similar problem I'll tell that mine came from this configuration on project.json:

...
"buildOptions": {
    "platform": "x86", <- THIS!!!
    "debugType": "portable",
    "preserveCompilationContext": true,
    "emitEntryPoint": true
},

after removing the "platform" key, migrations started to work again...

I'm not really sure when did I introduced that setting, since I didn't try to create migrations before upgrading to the version 1.1 of the .NET Core SDK. Maybe it was copied from one of the examples on internet, maybe it was from a previous version, I don't know, but that has turned me crazy for days, I hope it helps somebody outthere.

2
12/12/2016 5:46:30 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow