title: EntityCommandExecutionException was unhandled
body: <p>I am writing an application using EF 4.1 MVC3. I am trying to implement CRUD on it. The problem is that when i try to implement just first index page it gave me an error. I am using external database from central server. I am just trying a simple Registration form.
  I have first model class RegModel.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  namespace Registration.Models
  {
      public class Register
      {
          public int Id { get; set; }
          public string UserName { get; set; }
          public string Password { get; set; }
          public string Email { get; set; }
          public string Address { get; set; }
      }
  }
  </code></pre>
  
  <p>Then a RegModelContext.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  namespace Registration.Models
  {
      public class Register
      {
          public int Id { get; set; }
          public string UserName { get; set; }
          public string Password { get; set; }
          public string Email { get; set; }
          public string Address { get; set; }
      }
  }
  </code></pre>
  
  <p>My controller name is RegController.cs (I am just trying to implement Index first.) in controller. When i am executing my application it gave me error on <code>return View(db.Registrant.ToString());</code> that
   "entitycommandexecutionexception was unhandled"
   "An error occurred while executing the command definition. See the inner exception for details."</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using Registration.Models;
  using System.Configuration;
  
  
  namespace Registration.Controllers
  {
      public class RegController : Controller
      {
          //
          // GET: /Reg/
          private string CmdStr = ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString;      
          public ActionResult Index()
          {
              using (var db = new RegModelContext(CmdStr))
              {
                  return View(db.Registrant.ToString());
              }
  
          }
  
      }
  }
  </code></pre>
  
  <p>Then by using Index I create view for index (Index.cshtml):</p>
  
  <pre><code>@model IEnumerable&lt;Registration.Models.Register&gt;
  
  @{
      Layout = null;
  }
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Index&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;
          @Html.ActionLink("Create New", "Create")
      &lt;/p&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;th&gt;&lt;/th&gt;
              &lt;th&gt;
                  UserName
              &lt;/th&gt;
              &lt;th&gt;
                  Password
              &lt;/th&gt;
              &lt;th&gt;
                  Email
              &lt;/th&gt;
              &lt;th&gt;
                  Address
              &lt;/th&gt;
          &lt;/tr&gt;
  
      @foreach (var item in Model) {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
                  @Html.ActionLink("Details", "Details", new { id=item.Id }) |
                  @Html.ActionLink("Delete", "Delete", new { id=item.Id })
              &lt;/td&gt;
              &lt;td&gt;
                  @item.UserName
              &lt;/td&gt;
              &lt;td&gt;
                  @item.Password
              &lt;/td&gt;
              &lt;td&gt;
                  @item.Email
              &lt;/td&gt;
              &lt;td&gt;
                  @item.Address
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am using this web.config file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=152368
    --&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;
    &lt;/configSections&gt;
    &lt;appSettings&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0"&gt;
        &lt;assemblies&gt;
          &lt;add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
        &lt;/assemblies&gt;
      &lt;/compilation&gt;
      &lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="~/Account/LogOn" timeout="2880" /&gt;
      &lt;/authentication&gt;
      &lt;pages&gt;
        &lt;namespaces&gt;
          &lt;add namespace="System.Web.Helpers" /&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.Routing" /&gt;
          &lt;add namespace="System.Web.WebPages" /&gt;
        &lt;/namespaces&gt;
      &lt;/pages&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
    &lt;/system.webServer&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;connectionStrings&gt;
      &lt;add name="MyConn" connectionString="Data Source=WIN-A32JMN2HC3A\SAIGMAMSSQL;Initial Catalog=Registration;User Id=SAIGMA110;Password=12345;"/&gt;    
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>