problem with walkthrough

Jul 6, 2012 at 8:56 PM

I am following the sample exactly as mentioned in the starting guide

but I am getting following error in OnModelCreating

Code generated using the T4 templates for Database First and Model First development may not work correctly if used in Code First mode. To continue using Database First or Model First ensure that the Entity Framework connection string is specified in the config file of executing application. To use these classes, that were generated from Database First or Model First, with Code First add any additional configuration using attributes or the DbModelBuilder API and then remove the code that throws this exception.

public partial class NorthwindEFEntities : DbContext
        public NorthwindEFEntities()
            : base("name=NorthwindEFEntities")
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
            throw new UnintentionalCodeFirstException();
        public DbSet OrderDetails { get; set; }
        public DbSet Orders { get; set; }
        public DbSet Products { get; set; }
Can you please let me know where i could be wrong.
Sep 13, 2012 at 11:16 AM

Thank you for your feedback.

There was a problem in our getting started guide. The guide did provide instructions about how to override OnModelCreating() to avoid this error, but it did not mention that all custom code changes should happen in separate partial classes. So custom overrides of OnModelCreating() and other changes might be lost during Entity Data Model regeneration, meaning some people got it working, and some run into the same issue as you - we are sorry for that.

We fixed that problem in an updated guide, you may try it out again at .