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

EF Core Upgrade 1.0.1 to 1.1.0 does not support net4.6.1 / Tooling issue #7083

Closed
TPJ11 opened this issue Nov 21, 2016 · 3 comments
Closed

Comments

@TPJ11
Copy link

TPJ11 commented Nov 21, 2016

Steps to reproduce

  1. Create a project add a .NET core class library
  2. Create a Model E.G TestModel with some properties
  3. Create a DbContext class E.G TestDbContext
  4. Do the normal fix to make a class library run as a console app so EF migrations can run.
  5. Change class to use .net 4.6.1
  6. Add EF Core 1.0.1 using tools 1.0.0-preview2-final
  7. Add a migration (Add-Migration Create) (should work)
  8. Upgrade to EF Core 1.1.0 using tools 1.1.0-preview4-final
  9. Add a migration (Add-Migration Update) (should fail)

DbContext

`
public class TestDbContext : DbContext
{
public DbSet TestModels { get; set; }

    public TestDbContext() : base()
    {
    }

    public TestDbContext(DbContextOptions<TestDbContext> options) : base(options)
    {
    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
    }
}

public class TemporaryDbContextFactory : IDbContextFactory<TestDbContext>
{
    public TestDbContext Create(DbContextFactoryOptions options)
    {
        var builder = new DbContextOptionsBuilder<TestDbContext>();

        builder.UseSqlServer("##SQLConnectionString##");

        return new TestDbContext(builder.Options);
    }
}

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

    }
}

`

Model

` public class TestModel
{
[Key]
public int Id { get; private set; }

    public string Value { get; private set; }
}`

project.json EF 1.0.1

'{
"version": "1.0.0-*",

"buildOptions": {
"emitEntryPoint": true
},

"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
}
},

"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},

"frameworks": {
"net4.6.1": {}
}
}
'

project.json EF 1.1.0

'{
"version": "1.0.0-*",

"buildOptions": {
"emitEntryPoint": true
},

"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
}
},

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

"frameworks": {
"net4.6.1": {}
}
}
'

Work around

  1. Delete the old class library
  2. Recreate the class library
  3. Use only EF Core 1.1.0 and tools 1.0.0-preview2-final
  4. Run Add-Migration (should work)

The biggest issue I have is that I now cant downgrade the project as i get the same error and have to recreate the project (pain in the butt).

The issue

Unable to run EF commands / EF does not work on the new EF 1.1.0 when upgrading from 1.0.1 / Tools does not work not sure which...

Exception message:
targets framework 'net4.6.1'. The Entity Framework Core Package Manager Console Tools don't support this framework.

Further technical details

EF Core version: .NET 4.6.1
Operating system: Windows 8.1
Visual Studio version: VS 2015

@rowanmiller
Copy link
Contributor

Can you change:

"frameworks": {
  "net4.6.1": {}
}

to (note the removal of .s):

"frameworks": {
  "net461": {}
}

@TPJ11
Copy link
Author

TPJ11 commented Nov 22, 2016

@rowanmiller changed the framework (was I always doing it wrong or have they changed it?) anyway I'm now getting the following error

Unrecognized option '--config'

project.json file looks like

`{
"version": "1.0.0-*",

"buildOptions": {
"emitEntryPoint": true
},

"dependencies": {
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
}
},

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

"frameworks": {
"net461": {}
}
}`

I have also tried -

  1. Taking out Microsoft.EntityFrameworkCore.Tools from the tools section but get the following error

Cannot execute this command because 'Microsoft.EntityFrameworkCore.Tools' is not installed in project 'EF.Console.Core'. Add 'Microsoft.EntityFrameworkCore.Tools' to the 'tools' section in project.json. See http://go.microsoft.com/fwlink/?LinkId=798221 for more details.

  1. Taking out Microsoft.EntityFrameworkCore.Tools.DotNet from the tools section but get the following error -

No executable found matching command "dotnet-ef"

this error makes sense.

  1. Interestingly when i tried adding Microsoft.EntityFrameworkCore.Tools.DotNet to the dependencies section it brings up the following error message -

Image of the error

On the plus side I was able to downgrade back to 1.0.0-preview2 after upgrading to 1.1.0-preview4 without an issue :)

@rowanmiller
Copy link
Contributor

@TPJ11 having the periods was always wrong, but it looks like some of the project tooling was smart enough to "know what you meant" 😄.

The Unrecognized option '--config' issue is tracked by #7071 - unfortunately there isn't a good workaround, but you can roll back to the preview3 tools and keep using the 1.1 runtime. There are details about this in #7071.

BTW you can remove "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4", from the tools section, just the ...Tools.DotNet package needs to be there. It won't really change anything, it's just redundant.

Closing as the issue you are hitting how is already tracked elsewhere.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants