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: .NET Core CLI Implementation #3925

Closed
10 tasks done
bricelam opened this issue Nov 30, 2015 · 51 comments
Closed
10 tasks done

Commands: .NET Core CLI Implementation #3925

bricelam opened this issue Nov 30, 2015 · 51 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@bricelam
Copy link
Contributor

bricelam commented Nov 30, 2015

DNX commands will be going away with the transition to .NET Core CLI. We'll need to create a .NET Core CLI tools package instead. Like the NuGet PMC commands, any version of the command should be able to work with any version of the framework.

Known Issues

Usage

Your project.json should look something like this.

{
    "compilationOptions": {
        "emitEntryPoint": true
    },
    "tools": {
        "Microsoft.EntityFrameworkCore.Tools": { 
            "version": "1.0.0-*",
            "imports": "portable-net452+win81"
         }
    },
    "dependencies": {
        "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-*",
        "Microsoft.EntityFrameworkCore.Sqlite.Design": { "version": "1.0.0-*", "type": "build" },

        "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-*", "type": "build" }
    },
    "frameworks": {
        "netcoreapp1.0": {
            "imports": "portable-net452+win81",
            "dependencies": {
                "Microsoft.NETCore.App": { 
                     "version": "1.0.0-*",
                     "type": "platform"
                 }
            }
        }
    }
}

Your workflow will look something like this.

dotnet restore
cd src\MyProject
dotnet ef migrations add MyMigration
dotnet ef database update
@bricelam bricelam self-assigned this Nov 30, 2015
@bricelam
Copy link
Contributor Author

Open questions: (cc @davidfowl)

@AdamDotNet
Copy link

Will this ultimately resolve #3888?

@bricelam
Copy link
Contributor Author

bricelam commented Dec 1, 2015

@AdamDotNet No, either way we'll need to author the EF.Commands package (or whatever it ends up being called) to contain a ref\dotnet directory.

@rowanmiller rowanmiller added this to the 7.0.0-rc2 milestone Dec 8, 2015
Grinderofl pushed a commit to Grinderofl/EntityFramework that referenced this issue Jan 14, 2016
Changes:
* Use KoreBuild-dotnet (resolves dotnet#4280)
* Remove csproj-based solution
* Remove netcore50 targets
* Combine net451 & dnx451
* Remove DNX commands (see dotnet#3925)
Grinderofl pushed a commit to Grinderofl/EntityFramework that referenced this issue Jan 14, 2016
Changes:
* Use KoreBuild-dotnet (resolves dotnet#4280)
* Remove csproj-based solution
* Remove netcore50 targets
* Combine net451 & dnx451
* Remove DNX commands (see dotnet#3925)
@bricelam bricelam changed the title Commands: Make global NuGet tool package Commands: .NET Core CLI Implementation Jan 14, 2016
@bricelam bricelam mentioned this issue Feb 16, 2016
@natemcmaster
Copy link
Contributor

The rest of the Newtonsoft.Json story is here: https://github.com/dotnet/cli/issues/2514

@cevarief
Copy link

cevarief commented Apr 23, 2016

dotnet ef migrations add Init

Output :

System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
...
Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

When restoring package : Package Newtonsoft.Json 8.0.3 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0).

Config :

"frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dnxcore50",
        "net45"
      ],
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-*"
        }
      }
    }
  },
  "tools": {
    "dotnet-ef": "1.0.0-*"
  },

Nuget Feeds :

    <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
    <add key="AspNetCI" value="https://www.myget.org/F/aspnetcirelease/api/v3/index.json" />
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />

@cevarief
Copy link

Is there workaround to make it works ?

@cevarief
Copy link

I cleared all the nuget package and restore. The newton.json error has gone.
Another error when adding migration :

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: assemblyName
   at System.Reflection.AssemblyName..ctor(String assemblyName)
   at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName)

@patrickmichalina
Copy link

@cevarief I was able to get the tools started using this:

"tools": {
    "dotnet-ef": {
      "version":"1.0.0-*",
      "imports":["portable-net40+sl5+win8+wp8+wpa81"]
    }
  }

@patrickmichalina
Copy link

Nevermind... That just throws this...
capture

@moozzyk
Copy link

moozzyk commented Apr 24, 2016

You used an incorrect import "portable-net40+sl5+win8+wp8+wpa81" brought the Silverlight version. You need the import that has "dnxcore50" in it. Note that after you fix your import you have to clean your NuGet cache otherwise the error will not go away (you can clean all NuGet caches using nuget.exe locals -Clear all)

@cevarief
Copy link

I use the following import, but still can not successfully add migration. System.ArgumentNullException: Value cannot be null. Parameter name: assemblyName.

"dotnet-ef": {
      "version": "1.0.0-*",
      "imports": [
        "portable-net45+wp80+win8+wpa81+dnxcore50",
        "portable-net45+win8+wp8+wpa81",
        "portable-net45+win8+wp8"
      ]
    },

@mightea
Copy link

mightea commented Apr 25, 2016

@cevarief I had the same problem, issue #5065 specifies a workaround (commenting out MVC and Cors) in Startup.cs.

@cevarief
Copy link

cevarief commented Apr 25, 2016

@mightea Thanks. It works by commenting out addMvc() and addCors().

dotnet ef migrations add Init
Done. To undo this action, use 'ef migrations remove'

@natemcmaster
Copy link
Contributor

Heads up to anyone following this issue. We recently made big changes in #5142. "dotnet-ef" has been renamed to "Microsoft.EntityFrameworkCore.Tools". I've updated the sample usage in the issue description above to show what needs to be in project.json to use the tool now. #3925 (comment)

I'm leaving this issue open as we are still waiting on partners for fixes so that we can validate and ensure EF tools work.

@cevarief
Copy link

@natemcmaster What feed should we use to resolve Microsoft.EntityFrameworkCore.Tools, i use both aspnetcirelease and aspnetcidev and get this error :

Unable to resolve 'Microsoft.EntityFrameworkCore.Tools (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
Unable to resolve 'Microsoft.EntityFrameworkCore.Tools (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.

@natemcmaster
Copy link
Contributor

natemcmaster commented Apr 26, 2016 via email

@cevarief
Copy link

I've just tried to restore and now it works good. Thanks a lot 👍

@natemcmaster
Copy link
Contributor

Closing as we have finished with the implementation of .NET Core CLI commands. Any remaining bugs should be opened as a separate issue.

Additional work for post-RC2:
#5188
#5187
#5190

@gtbull80
Copy link

gtbull80 commented May 5, 2016

not sure if this is the right place for this...but any ideas?

PM> dotnet ef migrations add MyFirstMigration
dotnet.exe : Build failed.
At line:1 char:7

  • dotnet <<<< ef migrations add MyFirstMigration
    • CategoryInfo : NotSpecified: (Build failed.:String) [], RemoteException
    • FullyQualifiedErrorId : NativeCommandError

@natemcmaster
Copy link
Contributor

@gtbull80 dotnet-ef requires your project to build before it can add a migration. Run dotnet build to see the compilation errors.

@gtbull80
Copy link

gtbull80 commented May 6, 2016

Yeah...So I'm trying to wrap my head around all the new tech. Life's fun on the bleeding edge! When I run dotnet build , there are no errors...in fact there's no output at all. So I'm not sure if my environment configuration is wrong or I'm missing something else. I run the command in VS studio's package manager console from my project src{projectname} directory. I'm running an MVC6 app targeting RC2. My project.json:

{
    "userSecretsId": "aspnet5-EntityFrameworkTest-cd16c4bc-1228-4400-8b20-3c4076e2ed42",
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

    "dependencies": {
        "AspNet.Security.OAuth.Validation": "1.0.0-*",
        "IdentityModel": "2.0.0-*",
        "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*",
        "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-*",
        "Microsoft.AspNetCore.Cors": "1.0.0-*",
        "Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
        "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-*",
        "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-*",
        "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
        "Microsoft.AspNetCore.Mvc": " 1.0.0-*",
        "Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*",
        "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
        "Microsoft.AspNetCore.Razor": "1.0.0-*",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
        "Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
        "Microsoft.EntityFrameworkCore": "1.0.0-*",
        "Microsoft.EntityFrameworkCore.Commands": "1.0.0-rc3-20680",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-*",
        "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-*",
        "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-*",
        "Microsoft.Extensions.Configuration.Json": "1.0.0-*",
        "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
        "Microsoft.Extensions.Logging": "1.0.0-*",
        "Microsoft.Extensions.Logging.Console": "1.0.0-*",
        "Microsoft.Extensions.Logging.Debug": "1.0.0-*",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-*",
        "OpenIddict.Core": "1.0.0-*",
        "OpenIddict.EF": "1.0.0-*",
        "System.IdentityModel.Tokens": "5.0.0-*"       
    },

    "commands": {
        "web": "OpenIddictAuthorizationServerTest",
        "ef": "Microsoft.EntityFrameworkCore.Commands"
    },

    "frameworks": {
        "netcoreapp1.0": {
            "imports": "portable-net452+win81",
            "dependencies": {
                "Microsoft.NETCore.App": {
                    "version": "1.0.0-*"
                }
            }
        }
    },

    "exclude": [
        "wwwroot",
        "node_modules"
    ],
    "publishExclude": [
        "**.user",
        "**.vspscc"
    ],
    "scripts": {
        "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
    },
    "tools": {
        "dotnet-ef": "1.0.0-*"
    }
}

@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

No branches or pull requests