title: MVC4 - Value can not be null. Parameter name: source
body: <p>I create a new project in MVC4. I get this error:
  <code>System.ArgumentNullException: Value can not be null.
  Parameter name: source.</code>
  The database exists, the table exists and is filled with data.</p>
  
  <p>Any tips?</p>
  
  <p>Controler <strong>ShopController.cs</strong></p>
  
  <pre><code>...  
      SQLEntities DB = new SQLEntities();  
  
      public ActionResult Index()
      {
          var x = DB.Types.ToList();          &lt;-Here I get an exception
          return View(x);
      }
  ...
  </code></pre>
  
  <p>Model <strong>Type.cs</strong></p>
  
  <pre><code>using System.Collections.Generic;
  
  namespace xxx.Models
  {
      public class Type
      {
          public int TypeId { get; set; }
          public string Name { get; set; }
          public string Description { get; set; }
      }
  }
  </code></pre>
  
  <p>Model <strong>SQLEntities.cs</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data.Entity;
  using System.Linq;
  using System.Web;
  
  namespace xxx.Models
  {
      public class SQLEntities
      {
          public DbSet&lt;Type&gt; Types { get; set; }
      }
  }
  </code></pre>
  
  <p><strong>Web.config</strong></p>
  
  <pre><code>  &lt;connectionStrings&gt;
      &lt;add name="SQLEntities" connectionString="Data Source=KOMPUTER\SQLEXPRESS;Initial Catalog=myDB;Integrated Security=True;" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>The compiler doesn't indicate any error. It was only when he wants to go to <code>mypage/Shop</code> getting an exception.</p>
  
  <p><strong>stack trace</strong></p>
  
  <pre><code>{System.ArgumentNullException: Value can not be null.
  Parameter name: source.
         w System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
         w Print.Controllers.StoreController.Index() w c:\Users\John\Documents\Visual Studio 2013\Projects\Print\Print\Controllers\StoreController.cs:wiersz 18
         w lambda_method(Closure , ControllerBase , Object[] )
         w System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
         w System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
         w System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
         w System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass42.&lt;BeginInvokeSynchronousActionMethod&gt;b__41()
         w System.Web.Mvc.Async.AsyncResultWrapper.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _)
         w System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
         w System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
         w System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass37.&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33()
         w System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49()}
  </code></pre>