dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.83k stars 3.2k forks source link

Entity framework package manager console commands run from the wrong directory #7104

Closed aevitas closed 2 years ago

aevitas commented 8 years ago

Steps to reproduce

Create an ASP.NET Core project, add entity framework and define the following runtime in the project.json file:

"runtimes": {
    "win10-x64": {}
},

The issue

When running EF commands such as Add-Migration and Update-Database after defining a model, data context and everything required, the following error is provided:

PM> Add-Migration InitialModel
The specified deps.json [Z:\ryder\src\Ryder\bin\Debug\netcoreapp1.1\Ryder.deps.json] does not exist
Process finished with non-zero exit code

While the binaries generated at compile time are located in Z:\ryder\src\Ryder\bin\Debug\netcoreapp1.1\win10-x64

This means one has to continuously copy the contents of the win10-x64 directory up one directory in order for EF commands to run properly, which becomes tedious after a while.

Further technical details

EF Core version: 1.1 Operating system: Windows 10 x64 Visual Studio version: (e.g. VS 2013 or n/a): VS 2k15

Other details about my project setup:

My project.json looks as follows:

    "version": "1.0.0-*",

    "dependencies": {
        "JetBrains.Annotations": "10.2.1",
        "Microsoft.EntityFrameworkCore": "1.1.0",
        "Microsoft.EntityFrameworkCore.Design": "1.1.0",
        "Microsoft.EntityFrameworkCore.InMemory": "1.1.0",
        "Microsoft.EntityFrameworkCore.Relational.Design": "1.1.0",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
        "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
        "Microsoft.Extensions.Logging": "1.1.0",
        "NETStandard.Library": "1.6.1",
        "Newtonsoft.Json": "9.0.1",
        "NLog.Extensions.Logging": "1.0.0-rtm-alpha4",
        "Ryder.Common": "1.0.0-*",
        "System.ComponentModel": "4.3.0",
        "System.ComponentModel.Annotations": "4.3.0",
        "System.Diagnostics.StackTrace": "4.3.0",
        "System.Reflection.TypeExtensions": "4.3.0"
    },

    "tools": {
        "Microsoft.EntityFrameworkCore.Design": "1.1.0",
        "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
        "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"
    },

    "frameworks": {
        "netstandard1.6": {
            "imports": "dnxcore50"
        }
    }
}

I'm assuming this issue is with EF and not .NET Core, though I'm not entirely sure. The code won't compile without a runtime defined.

Has anyone else run into this issue with EF Core 1.1?

majidgorbani commented 8 years ago

almost same problem for me! { "dependencies": { "Microsoft.AspNetCore.Diagnostics": "1.1.0", "Microsoft.AspNetCore.Mvc": "1.1.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", "Microsoft.AspNetCore.StaticFiles": "1.1.0", "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0", "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final", "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", "Microsoft.Extensions.Logging.Console": "1.1.0", "Microsoft.NETCore.App": "1.1.0" },

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

majidgorbani commented 8 years ago

try this:

"dependencies": {

"Microsoft.AspNetCore.Diagnostics": "1.1.0",

"Microsoft.AspNetCore.Mvc": "1.1.0",

"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",

"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",

"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",

"Microsoft.AspNetCore.StaticFiles": "1.1.0",

"Microsoft.EntityFrameworkCore": "1.1.0",

"Microsoft.EntityFrameworkCore.Design": "1.1.0",

"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",

"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",

"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",

"Microsoft.Extensions.Configuration.Json": "1.1.0",

"Microsoft.Extensions.Logging.Console": "1.1.0",

"Microsoft.Extensions.Logging.Debug": "1.0.0",

"Microsoft.NETCore.App": {

  "type": "platform",

  "version": "1.1.0"

},

"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"

},

"tools": {

"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",

"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"

},

modestob commented 8 years ago

EF Core 1.1 cannot run dotnet ef commands after fixing recommended changes cannot run add-migrations

    "version": "1.1.0-*",
    "dependencies": {
        "DevExtreme.AspNet.Mvc": "16.2.1",
        "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
        "Microsoft.AspNetCore.StaticFiles": "1.1.0",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
        "Microsoft.Extensions.Configuration.Json": "1.1.0",
        "Microsoft.Extensions.Logging": "1.1.0",
        "Microsoft.Extensions.Logging.Console": "1.1.0",
        "Microsoft.Extensions.Logging.Debug": "1.1.0",
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
        "Microsoft.AspNetCore.Diagnostics": "1.1.0",
        "Microsoft.AspNetCore.Mvc": "1.1.0",
        "Microsoft.AspNetCore.Routing": "1.1.0",
        "Microsoft.AspNetCore.Routing.Abstractions": "1.1.0",
        "Microsoft.AspNetCore.Razor": "1.1.0",
        "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.1.0",
        "Microsoft.AspNetCore.Razor.Tools": {
            "version": "1.1.0-preview4-final",
            "type": "build"
        },
        "Microsoft.AspNetCore.Mvc.DataAnnotations": "1.1.0",
        "Microsoft.AspNetCore.Mvc.Formatters.Json": "1.1.0",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
        "Microsoft.NETCore.App": {

            "type": "platform",

            "version": "1.1.0"

        },

        "Microsoft.EntityFrameworkCore": "1.1.0",
        "Microsoft.EntityFrameworkCore.Design": "1.1.0",
        "Microsoft.EntityFrameworkCore.Relational": "1.1.0",
        "Microsoft.EntityFrameworkCore.Relational.Design": "1.1.0",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
        "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
        "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
        "DX.JavaScript.WebAPI.Client": "1.0.0.10",
        "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
        "LinqKit.Microsoft.EntityFrameworkCore": "1.1.9"
    },

    "tools": {
        "BundlerMinifier.Core": "2.2.306",
        "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
        // "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
        "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"

    },

    "frameworks": {
        "netcoreapp1.1": {
            "imports": [ "dnxcore50", "net461", "dotnet" ] //dotnet //dnxcore50
        }
    },

    "buildOptions": {
        //   "debugType": "portable",
        "emitEntryPoint": true,
        "preserveCompilationContext": true
    },

    "runtimeOptions": {
        "configProperties": {
            "System.GC.Server": true
        }
    },

    "publishOptions": {
        "include": [
            "wwwroot",
            "**/*.cshtml",
            "Views",
            "Areas/**/Views",
            "appsettings.json",
            "web.config"
        ]
    },

    "scripts": {
        "prepublish": [ "bower install", "dotnet bundle" ],
        "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
    }
}
bricelam commented 7 years ago

@aevitas This looks like a dupe of #7077

bricelam commented 7 years ago

@modestob what error are you seeing?

modestob commented 7 years ago

I could not use dotnet.ef commands

I tried Rowan's suggestions and now it works used "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview3-final", saw it in another thread.... Thank you bricelam for the follow up

divega commented 7 years ago

@bricelam you meant to close this too?

aevitas commented 7 years ago

@bricelam Yes, I agree it's the same issue. Thanks for the follow up!

I'm assuming you meant to close this issue, so I'll do it and keep track #7077