EF Migrations: The parameter 'frameworkName' cannot be an empty string

c# entity-framework entity-framework-core nuget

Question

I'm following some tutorials on plural sight on how to setup my first web api using .netcore. I'm having an issue trying to run my first migration:

PM> Add-Migration InitialMigration Exception calling ".ctor" with "1" argument(s): "The parameter 'frameworkName' cannot be an empty string. Parameter name: frameworkName"

I understand it's saying there is a constructor somewhere with one argument that is empty; however, I have no idea where this "frameworkName" parameter is. I'm assuming it's some internal EF mechanism.

What class is this error message referencing?

This is my simple entity setup

public class ShackupContext : DbContext
{
    public DbSet<Post> Posts { get; set; }
    public ShackupContext(DbContextOptions<ShackupContext> options):base(options)
    {

    }
}  


    public class Post
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }
    [Required]
    [MaxLength(200)]
    public string Name { get; set; }
}  

UPDATE 1 I have updated my dbcontext to call the base class constructor as @ViktorsTelle suggested.

My project is setup different than any tutorials I have followed. The main difference is my entities are contained in their own project as opposed to being in the api project itself.
enter image description here
This led me to believe that running Add-Migration on the Shackup.Data project itself did not require me to register my dbcontext inside of my api project. I did it anyway to see what would happen:

 public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddMvc();
        services.AddDbContext<ShackupContext>(o => 
        o.UseNpgsql(Configuration["connectionStrings:postgres"],
        a => a.MigrationsAssembly("Shackup.Data")));
    }  

Once I did that I managed to get a little further in the migration process. I am now getting
PM> Add-Migration InitialMigration The specified deps.json [C:\Users\campo\Documents\Visual Studio 2015\Projects\Shackup\src\Shackup.Api\bin\Debug\netcoreapp1.1\Shackup.Api.deps.json] does not exist Process finished with non-zero exit code

So I took a look at that directory and indeed it was missing the file; however, the file is being output to a child folder of that directory.

enter image description here

The deps.json file is located inside the win10-x64 folder. I can simply copy and paste to the required folder but now I am faced with a new question:

Why is Nuget package manager console looking in the wrong directory?
Or possibly: How can I change this to look in the correct place?

Update 2

I have updated all my project dependencies in both projects. Here are the two files for the data and the api projects below

API

{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "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": "1.1.0",
"Shackup.Data": "1.0.0-*",
"Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
},

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

"frameworks": {
"netcoreapp1.1": {
  "imports": [
    "dotnet5.6",
    "portable-net45+win8"
  ]
}
},

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

"runtimeOptions": {
"configProperties": {
  "System.GC.Server": true
}
},
"runtimes": {
"win10-x64": {},
"win81-x64": {}
},

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

"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}  

DATA

{
"version": "1.0.0-*",

"dependencies": {
"Microsoft.EntityFrameworkCore": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"NETStandard.Library": "1.6.1"
},

 "frameworks": {
"netstandard1.6": {
  "imports": "dnxcore50"
}
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
}
}
1
4
12/21/2016 7:19:59 PM

Popular Answer

Select proper Startup Project in your solution : Right-click on your project in the solution explorer, select "Set as startup project"

8
3/20/2018 7:14:46 AM


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