C# Entity Framework Basics Entity Framework and Databases Controlling Database Generation

olu adesina
PRO
olu adesina
Pro Student 19,018 Points

where im i going wrong with Database.SetInitializer

not sure what im doing wrong here it asks does context have one parameters

Context.cs
using System.Data.Entity;

namespace Treehouse.CodeChallenges
{
    public class Context : DbContext
    {
         Context()
        {
            Database.SetInitializer(new DropCreateDatabaseAlways<Context>());
        }
        public DbSet<Course> Courses { get; set; }
    }
}

1 Answer

Steven Parker
Steven Parker
177,888 Points

It couldn't find the constructor because it's missing the "public" access modifier.

Otherwise, it looks like you've got it. :+1: