Code-first migration in Entity Framework Core error

c# entity-framework-core

Question

I am a .NET student. So please be patient with me. Apart from adding this question here I search web tirelessly to find a solution to my problem. Thank you for understanding.

I am trying to migrate a code-first project with Entity Framework Core just so I can familiarize my self with all the commands and procedures.

The problem I am getting is when a try to migrate. I am writing the line

add-migration Initial-Migration -context BlogContext

in the Package Manager Console. The error I am getting is this one:

Error message

These are my dependencies:

{
  "dependencies": {
    "BundlerMinifier.Core": "2.2.306",
    "EntityFramework.Core": "7.0.0-rc1-final",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Routing": "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.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.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0"
  },

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

Tell me if there is anything more you would like to see. I am grateful for all the help I get.

EDIT:

My BlogContext: BlogContext

New error from VS Package manager Console:

enter image description here

1
0
12/21/2016 2:44:57 PM

Accepted Answer

  1. Remove "EntityFramework.Core": "7.0.0-rc1-final", dependency (line 3 in listing) - it's old version of Microsoft.EntityFrameworkCore and it may add some old/undesired libs to you app

  2. Run dotnet restore from command line (from src/Blogg folder) to refresh package list (VS should do it automatically, but we need to be sure).

  3. Manually remove bin and obj folders

  4. Run dotnet ef migrations add BlogContext from command line (from src/Blogg folder)

1
12/21/2016 2:18:00 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