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 trialmarcolamoon
16,915 PointsHELP with framework question??
In Configuration.cs update the Seed method so that the database is only seeded with the students test data when the application is being built with the Debug build configuration. To do that, wrap the call to the context's Students DbSet property's AddOrUpdate method in an #if preprocessor directive and test for the presence of the DEBUG symbol.
I keep getting bummer and i;m not for sure whats wrong.
using System.Data.Entity.Migrations;
namespace Treehouse.CodeChallenges
{
public class Configuration : DbMigrationsConfiguration<Context>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
#if DEBUG
protected override void Seed(Context context)
{
context.Students.AddOrUpdate(
s => s.Id,
new Student() { Id = 1, FirstName = "John", LastName = "Smith" },
new Student() { Id = 2, FirstName = "Sally", LastName = "Jones" }
);
#endIf
}
}
}
2 Answers
Steven Parker
231,210 PointsAlways make sure parentheses and braces match inside a conditional.
Otherwise, when the condition is not met, the code will not compile.
Also, you don't want to make the method itself conditional, just the code in the body.
Matthew Miles
13,770 Pointsyou also capitalized the 'if' in #endIf. try #endif
marcolamoon
16,915 Pointsmarcolamoon
16,915 Pointsso i just noticed it wants me to change " protected override void Seed(Context context)" but i'm not sure what to change it to. i re watch the video and still don't get it.
Steven Parker
231,210 PointsSteven Parker
231,210 PointsI'm not sure what you mean. But if you just move that "
#if DEBUG
" to the correct line it will pass the challenge.