title: Can't add new model and update database in mvc 5 project?
body: <p>I'm having an issue with the current project I'm working on. It works fine and runs without error with it's current classes and functionality. My issue is that I can't seem to add another model, it's corresponding controller and views and get it to actually work.</p>
  
  <p>Usually I would simply add a new model class to the folder, update my dbcontext class with a dbset with the new model as datatype. Then write "update-database -force" in the package manager console and it would apply the automatic migrations. But for some strange reason I can't seem to comprehend, it simply won't do that anymore.</p>
  
  <p>Instead, after I create the model and add the dbset and then trying to update database it runs the update fine, but it doesn't add any new migrations. The funny thing is when I run the project I get the usual error you always get when you have forgotten to update the database where it's recommending code first migrations etc.</p>
  
  <p>I tried checking my config file and it seems the context key is set to applicationuser instead of the proper dbcontext class, which I'm sensing is why it doesn't detect any changes(usually it figures this out itself?). But when I try changing it to the proper one and updating the database again, it gives me an error saying something about asproles is already in the database?</p>
  
  <p>I'm completely lost here and would appreciate any input an experienced vs13 user can give me.</p>
  
  <p>EDIT:
  I should mention I have been working on the identity framework recently, which is probably why it has automatically changed the contextkey? But I haven't had any issues during that with any of my existing classes.</p>
  
  <p><strong>NEW EDIT (29-01-2015)</strong>
  Relevant part of configuration file:</p>
  
  <pre><code>  internal sealed class Configuration : DbMigrationsConfiguration&lt;MEV3.Models.ApplicationDbContext&gt;
      {
          public Configuration()
          {
              AutomaticMigrationsEnabled = true;
              ContextKey = "MEV3.Models.QuestionContext";
          }
          protected override void Seed(MEV3.Models.ApplicationDbContext context)
          {
              //  This method will be called after migrating to the latest version.
  
              //  You can use the DbSet&lt;T&gt;.AddOrUpdate() helper extension method 
              //  to avoid creating duplicate seed data. E.g.
              //
              //    context.People.AddOrUpdate(
              //      p =&gt; p.FullName,
              //      new Person { FullName = "Andrew Peters" },
              //      new Person { FullName = "Brice Lambson" },
              //      new Person { FullName = "Rowan Miller" }
              //    );
              this.AddUserAndRoles();
          }
  </code></pre>
  
  <p>My QuestionContext file:</p>
  
  <pre><code>namespace MEV3.Models
  {
      public class QuestionContext : DbContext
      {
          public DbSet&lt;ExamSet&gt; ExamSets { get; set; }
  
          public DbSet&lt;BlanketSet&gt; BlanketSets { get; set; }
  
          public DbSet&lt;LooseQuestionCase&gt; LooseQuestionCases { get; set; }
  
          public DbSet&lt;Medcase&gt; Medcases { get; set; }
  
          public DbSet&lt;Question&gt; Questions { get; set; }
  
          public DbSet&lt;QuestionChoice&gt; QuestionChoices { get; set; }
  
          public DbSet&lt;QuestionBeforeAfter&gt; QuestionBeforeAfters { get; set; }
  
          public DbSet&lt;Answer&gt; Answers { get; set; }
  
          public DbSet&lt;Tag&gt; Tags { get; set; }
  
          public DbSet&lt;Category&gt; Categories { get; set; }
  
          public DbSet&lt;Institution&gt; Institutions { get; set; }
  
          public DbSet&lt;ExamType&gt; ExamTypes { get; set; }
  
          public DbSet&lt;NewsArticle&gt; NewsArticles { get; set; }
  
          //public DbSet&lt;TaskRecord&gt; TaskRecords { get; set; }
  
          //protected override void OnModelCreating(DbModelBuilder modelBuilder)
          //{  
          //    modelBuilder.Conventions.Remove&lt;OneToManyCascadeDeleteConvention&gt;();
          //}
  
      }
  </code></pre>
  
  <p>My ApplicationDbContext file:</p>
  
  <pre><code>public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
      {
  
          public ApplicationDbContext()
              : base("DefaultConnection")
          {
  
          }
  
          public DbSet&lt;TaskRecord&gt; TaskRecords { get; set; }
  
      }
  </code></pre>
  
  <p>When I have the contextkey set to my QuestionContext and try to make changes to any models in that dbset, it gives me an error about the taskrecords (which is strange cuz they are inside the applicationdbcontext class).</p>
  
  <p>This means I can't make any succesful updates of the database if I try to change a model in the QuestionContext.</p>
  
  <p>If I set the contextkey to ApplicationDbContext I can make changes to anything in the applicationdbcontext succesfully, but it wont register any changes done in any of the models in the QuestionContext.</p>
  
  <p>I'm at a loss, the way it works now it seems I can only add new models to the applicationdbcontext or change models in it, can't go back and alter anything in the questioncontext. Any thoughts?</p>
  
  <p>Automatic migrations are succesfully enabled on both contexts btw. I've used this setup succesfully before I started fiddling with the identityframework.</p>