title: MySql and Entity Framework Code First
body: <p>I have a problem with MySql and Entity Framework Code First.</p>
  
  <p>My Connection String at the web.config.xml</p>
  
  <pre><code>&lt;add name="EntityContext" connectionString="Server=127.0.0.1; port=8080 Database=simple_crud; Uid=root; Pwd=;" providerName="MySql.Data.MySqlClient" /&gt;
  </code></pre>
  
  <p>My Context:</p>
  
  <pre><code>public class EntityContext : DbContext
  {
      public DbSet&lt;Pessoa&gt; Pessoas { get; set; }
  }
  </code></pre>
  
  <p>My Class:</p>
  
  <pre><code>[Table("pessoa")]
  public class Pessoa
  {
      [Key]
      [Column("Id")]
      public int Id { get; set; }
  
      [Column("Nome")]
      public string Nome { get; set; }
  }
  </code></pre>
  
  <p>My Controller</p>
  
  <pre><code>public EntityContext db = new EntityContext();
  
  public ActionResult Index()
  {
       List&lt;Pessoa&gt; pessoas = db.Pessoas.ToList(); // here is the error
       return View(pessoas);
  }
  </code></pre>
  
  <p>So, when I press F5 I got this: "Input string was not in a correct format".</p>
  
  <p>What I'm miss?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Stack Trace:</p>
  
  <blockquote>
    <p>[FormatException: Input string was not in a correct format.]<br>
    System.Number.StringToNumber(String str, NumberStyles options,
    NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
    +9591147    System.Number.ParseUInt32(String value, NumberStyles options, NumberFormatInfo numfmt) +119<br>
    System.String.System.IConvertible.ToUInt32(IFormatProvider provider)
    +46    System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +9509065<br>
    MySql.Data.MySqlClient.MySqlConnectionStringBuilder.ChangeType(Object
    value, Type t) +240<br>
    MySql.Data.MySqlClient.MySqlConnectionStringBuilder.SetValue(String
    keyword, Object value) +399<br>
    MySql.Data.MySqlClient.MySqlConnectionStringBuilder.set_Item(String
    keyword, Object value) +54<br>
    System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String
    value) +127<br>
    MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString(String
    value) +289<br>
    System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
    name) +409<br>
    System.Data.Entity.Internal.LazyInternalConnection.Initialize() +49<br>
    System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
    +10    System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
    +265    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
    entityType) +17<br>
    System.Data.Entity.Internal.Linq.InternalSet<code>1.Initialize() +62<br>
    System.Data.Entity.Internal.Linq.InternalSet</code>1.GetEnumerator() +15<br>
    System.Data.Entity.Infrastructure.DbQuery<code>1.System.Collections.Generic.IEnumerable&lt;TResult&gt;.GetEnumerator()
    +40    System.Collections.Generic.List</code>1..ctor(IEnumerable<code>1 collection) +315    System.Linq.Enumerable.ToList(IEnumerable</code>1
    source) +58    SimpleMysqlCrud.Controllers.PessoaController.Index() in
    f:\users\pablo.rocha.fti\documents\visual studio
    2010\Projects\SimpleMysqlCrud\SimpleMysqlCrud\Controllers\PessoaController.cs:16
    lambda_method(Closure , ControllerBase , Object[] ) +62<br>
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
    controller, Object[] parameters) +17<br>
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
    controllerContext, IDictionary<code>2 parameters) +208<br>
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
    controllerContext, ActionDescriptor actionDescriptor, IDictionary</code>2
    parameters) +27<br>
    System.Web.Mvc.&lt;>c_<em>DisplayClass15.b</em>_12()
    +55    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
    filter, ActionExecutingContext preContext, Func<code>1 continuation) +263<br>
    System.Web.Mvc.&lt;&gt;c__DisplayClass17.&lt;InvokeActionMethodWithFilters&gt;b__14()
    +19    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext
    controllerContext, IList</code>1 filters, ActionDescriptor actionDescriptor,
    IDictionary<code>2 parameters) +191<br>
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
    controllerContext, String actionName) +343<br>
    System.Web.Mvc.Controller.ExecuteCore() +116<br>
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
    +97    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
    requestContext) +10<br>
    System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +37<br>
    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +21<br>
    System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8</code>1.b__7(IAsyncResult
    <em>) +12    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62    System.Web.Mvc.&lt;>c</em>_DisplayClasse.b_<em>d() +50<br>
    System.Web.Mvc.SecurityUtil.b</em>_0(Action f) +7 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
    +22    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60<br>
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
    result) +9<br>
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    +8970141    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +184</p>
  </blockquote>