Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Migrations Getting Started with Using Migrations Using the Configuration Class to Add Seed Data

can't do it

I do everything it tells me and try again but it doesn't work

Configuration.cs
using System.Data.Entity.Migrations;

namespace Treehouse.CodeChallenges
{
    public class Configuration : DbMigrationsConfiguration<Context>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(Context context)
        {
            // TODO Add student test data.
        }
    }
}
Context.cs
using System.Data.Entity;

namespace Treehouse.CodeChallenges
{
    public class Context : DbContext
    {
        public Context ()
        {
            Database.SetInitializer<Context>(null);
        }

        public virtual DbSet<Student> Students  { get; set; }
    }
}
Student.cs
namespace Treehouse.CodeChallenges
{
    public class Student
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
}

1 Answer

Steven Parker
Steven Parker
229,759 Points

It doesn't look like you've written any code yet.

If you'd done "everything it tells you", there would be some code under the comment line "// TODO Add student test data.".

At least please give it a good-faith attempt and then ask for help if you have trouble, showing the code you have written.