title: Entity Framework Enable-Migrations Null Reference Exception
body: <p>I'm unable to get Code First migrations working properly on my Visual Studio 2013 project. I'm using EF 6.1 and C#.Net 4.5. When I try to run <code>Enable-Migrations</code> or <code>Enable-Migrations -ContextTypeName DataContext</code> I get the following error:</p>
  
  <pre><code>PM&gt; Enable-Migrations -ContextTypeName DataContext -Force
  Checking if the context targets an existing database...
  System.NullReferenceException: Object reference not set to an instance of an object.
     at Infrastructure.DataAccess.DataContext..ctor() in c:\Users\mblack\Documents\Visual Studio 2013\Projects\BluemoonApp\Infrastructure\DataAccess\DataContext.cs:line 16
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Data.Entity.Infrastructure.DbContextInfo.CreateInstance()
     at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func1 resolver)
     at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase)
     at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
     at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
     at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run()
     at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
     at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
     at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
     at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldInitialCreate(String language, String rootNamespace)
     at System.Data.Entity.Migrations.EnableMigrationsCommand.&lt;&gt;c__DisplayClass2.&lt;.ctor&gt;b__0()
     at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
  Object reference not set to an instance of an object.
  </code></pre>
  
  <p>I cannot figure out why this won't work. I've tried re-installing EntityFramework via Nuget Package Manager Console, as well as deleting the Migrations folder then trying to "Re-Enable" migrations.</p>
  
  <p>Please let me know if there's any additional information you need, thanks</p>
  
  <p>EDIT: Adding DataContext.cs and DataContextInitializer.cs</p>
  
  <pre><code>namespace Infrastructure.DataAccess
  {
      public class DataContext : DbContext
      {
          public DataContext()
              : base(ConfigurationManager.ConnectionStrings["BluemoonDev"].ConnectionString)
          {
              Configuration.ProxyCreationEnabled = false;
          }
  
          public virtual DbSet&lt;Task&gt; Tasks { get; set; }
          public virtual DbSet&lt;Test&gt; Tests { get; set; }
          public virtual DbSet&lt;Core.Models.Configuration&gt; Configurations { get; set; }
          public virtual DbSet&lt;Subscriber&gt; Subscribers { get; set; }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              //modelBuilder.Entity&lt;Task&gt;().HasKey(t =&gt; t.TaskId);
  
  
              base.OnModelCreating(modelBuilder);
          }
      }
  }
  
  namespace Infrastructure.DataAccess
  {
      public class DataContextInitializer : DropCreateDatabaseIfModelChanges&lt;DataContext&gt;
      {
          protected override void Seed(DataContext context)
          {
              // . . . Creating lists for each Entity
              // . . . Adding those items to context and saving changes
          }
      }
  }
  </code></pre>