title: failed to set database initializer
body: <p>I'm learning ASP.NET MVC5 to make a website. I created several classes in the model folder and used "scaffolding feature" in Entity Framework to create CRUD pages. Everything is fine in the Home page. But when I clicked the "Employee" link in the navigation bar, there was an error in this line: </p>
  
  <pre><code>public ActionResult Index()
  {
      return View(db.Employees.ToList());
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code
  Additional information: Failed to set database initializer of type 'wms.DAL.ProductInitilizer, wms' for DbContext type 'wms.DAL.ProductContext, wms' specified in the application configuration. See inner exception for details.
  </code></pre>
  
  <p>Here is <code>Employee</code> class:</p>
  
  <pre><code>public class Employee
  {
      public string ID { get; set; }
      public string Name { get; set; }
      public string Department { get; set; }
      public string Post { get; set; }
      public string PS { get; set; }
      public virtual ICollection&lt;Purchase&gt; Purchases { get; set; }
      public virtual ICollection&lt;Delivery&gt; Deliveries { get; set; }
      public virtual ICollection&lt;Stock&gt; Stocks { get; set; }
  }
  </code></pre>
  
  <p>part of <code>ProductInitializer</code>:</p>
  
  <pre><code>namespace wms.DAL
  {
      public class ProductInitializer : System.Data.Entity.DropCreateDatabaseAlways&lt;ProductContext&gt;
      {
          protected override void Seed(ProductContext context)
          {
              ...
              var employees = new List&lt;Employee&gt;
              {
                  new Employee{ID="238047AF1",Name="Bill",Department="Storage",Post="worker",PS="default"},
                  new Employee{ID="2457656AB",Name="Bob",Department="Storage",Post="worker",PS="default"}
              };
              employees.ForEach(s =&gt; context.Employees.Add(s));
              context.SaveChanges();
          }
      }
  }
  </code></pre>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
        &lt;section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /&gt;
        &lt;section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /&gt;
      &lt;/sectionGroup&gt;
    &lt;/configSections&gt;
  
    &lt;system.web.webPages.razor&gt;
      &lt;host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
      &lt;pages pageBaseType="System.Web.Mvc.WebViewPage"&gt;
        &lt;namespaces&gt;
          &lt;add namespace="System.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
          &lt;add namespace="System.Web.Mvc.Html" /&gt;
          &lt;add namespace="System.Web.Optimization"/&gt;
          &lt;add namespace="System.Web.Routing" /&gt;
          &lt;add namespace="wms" /&gt;
        &lt;/namespaces&gt;
      &lt;/pages&gt;
    &lt;/system.web.webPages.razor&gt;
  
    &lt;appSettings&gt;
      &lt;add key="webpages:Enabled" value="false" /&gt;
    &lt;/appSettings&gt;
  
    &lt;system.webServer&gt;
      &lt;handlers&gt;
        &lt;remove name="BlockViewHandler"/&gt;
        &lt;add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /&gt;
      &lt;/handlers&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>What's wrong here? I've been digging for a long time but couldn't find the reason.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>inner exception: </p>
  
  <pre><code>System.InvalidOperationException was unhandled by user code
    HResult=-2146233079
    Message=Failed to set database initializer of type 'wms.DAL.ProductInitilizer, wms' for DbContext type 'wms.DAL.ProductContext, wms' specified in the application configuration. See inner exception for details.
    Source=EntityFramework
    StackTrace:
         System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func`1 initializerArgs, Func`3 exceptionMessage)
         System.Data.Entity.Internal.InitializerConfig.&lt;&gt;c__DisplayClass6.&lt;TryGetInitializerFromEntityFrameworkSection&gt;b__1(ContextElement e)
         System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
         System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
         System.Data.Entity.Internal.InitializerConfig.TryGetInitializerFromEntityFrameworkSection(Type contextType)
         System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type contextType)
         System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type, String name)
         System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.&lt;&gt;c__DisplayClass1.&lt;GetService&gt;b__0(Tuple`2 t)
         System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
         System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key)
         System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.&lt;&gt;c__DisplayClass3.&lt;GetService&gt;b__0(IDbDependencyResolver r)
         System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
         System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
         System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key)
         System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key)
         System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService(IDbDependencyResolver resolver, Type type)
         System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
         System.Data.Entity.Internal.LazyInternalContext.&lt;InitializeDatabase&gt;b__4(InternalContext c)
         System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
         System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
         System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
         System.Data.Entity.Internal.InternalContext.Initialize()
         System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
         System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
         System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
         System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable&lt;TResult&gt;.GetEnumerator()
         System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
         System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         wms.Controllers.EmployeeController.Index() Location c:\Users\cityofsky\Documents\Visual Studio 2013\Projects\wms\wms\Controllers\EmployeeController.cs:Line 21
         lambda_method(Closure , ControllerBase , Object[] )
         System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
         System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
         System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
         System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
         System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;BeginInvokeSynchronousActionMethod&gt;b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
         System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
         System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
         System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
         System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
         System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3d()
         System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f()
    InnerException: System.TypeLoadException
         HResult=-2146233054
         Message=Could not load type "wms.DAL.ProductInitilizer" from assembly "wms"
         Source=mscorlib
         TypeName=wms.DAL.ProductInitilizer
         StackTrace:
              System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
              System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
              System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark)
              System.Type.GetType(String typeName, Boolean throwOnError)
              System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func`1 initializerArgs, Func`3 exceptionMessage)
         InnerException: 
  </code></pre>