I'm trying to use scaffolding to generate MVC Controller with views, using Entity Framework:
I created ApplicationDBContext:
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public DbSet<med1.Models.House> House { get; set; }
}
and added to ConfigureServices:
services.AddDbContext<Data.ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
And of course I have House model:
public class House
{
public int ID { get; set; }
public string HouseName { get; set; }
public string Address1 { get; set; }
public int CityID { get; set; }
public City City { get; set; }
public string ZIP { get; set; }
public int StateID { get; set; }
public State State { get; set; }
}
I got following error:
Okay, I added parameterless constructor to ApplicationDBContext:
public ApplicationDbContext() { }
And got the following error:.
Actually I had the same problem with previous project and created Controller and View manually.
But for this project I'd like to use scaffolding.
I'm doing something wrong or it's VS 2017 preview problem?