PetaPOCO, MySQL & ASP.NET MVC

web.config settings-
<configuration>
  <connectionStrings>
    <add name="MySqlConnection" connectionString="Server=192.168.100.30;Port=3306;Database=grocery_db; User ID=root; Password=*****;" providerName="MySql.Data.MySqlClient" />   
  </connectionStrings>

 <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>
</configuration>


Controller code-

public ActionResult Summary()
{
    //string connectionString
    GrocerySummaryViewModel viewModel = new GrocerySummaryViewModel();
    List<GroceryWiseContactQuantity> groceryContactList = new List<GroceryWiseContactQuantity>();
    try
    {
        var db = new PetaPoco.Database("MySqlConnection");
        groceryContactList = db.Query<GroceryWiseContactQuantity>("SELECT grocery AS GroceryName, count(id) AS Quantity FROM contacts group by grocery order by count(id) desc").ToList();
                
        viewModel.GroceryWiseContactList = groceryContactList;
                
    }
    catch (Exception Ex)
    {
        this.LogException(Ex);
    }
    return View("GrocerySummary", viewModel); 
}

C# MySQL Connection

MySql.Data 6.9.8
PM> Install-Package MySql.Data

using MySql.Data.MySqlClient;

MySqlConnection Con = new MySqlConnection("Server=111.222.333.444; Port=3306; Database=grocery_db;Uid=root;Pwd=****");
Con.Open();
DataTable Table = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter("select id, name from contacts order by name",Con);
da.Fill(Table);
Con.Close();