Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Unable to scaffold a new controller with Entity Framework Core in ASP.Net Core 2.0

$
0
0

I'm not 100% sure this has to do with ASP.Net Core, but think so.

I'm going over this tutorial on ASP.Net core , and am using VS 2017 to do so-- https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db

In so doing, I can get to the point where it asks me to scaffold a new controller using EF, at which point I get told "There was an error running the selected code generator: 'No parameterless constructor defined for this object'."

Sure enough, my generated DBContext class does not have a parameterless constructor.  Instead, it reads like so:

 public partial class Northwind_v1Context : DbContext
    {
        public Northwind_v1Context(DbContextOptions<Northwind_v1Context> options) : base(options)
        {
        }

        public virtual DbSet<Categories> Categories { get; set; }
        public virtual DbSet<CategoryLang> CategoryLang { get; set; }
        public virtual DbSet<CustomerCustomerDemo> CustomerCustomerDemo { get; set; }
//etc

Is there something I'm doing wrong, and/or is there a workaround?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>