Peter Goodman bio photo

Peter Goodman

A software engineer and leader living in Auckland building products and teams. Originally from Derry, Ireland.

Twitter Google+ LinkedIn Github

After moving my blog to wordpress, I decided to update the recent posts section on my main site to point to the wordpress repository instead of the old SubText one. SubText was using MSSQL but Wordpress is using MySQL so I had to get things strung together again.

For the original code talking to the SubText repository I had created an EDMX and simply queried against it using LINQ to extract the top 5 most recent blog posts and display them on my sites main page.

The first thing I figured I would have to do is to find a connector for MySQL to allow the Entity Framework to talk to MySQL. A quick google supplied me with the location to go pick that provider up directly from the guys at MySQL.Once that was installed I had to restart VS2010 and go through the process of adding a new EDMX model for the WordPress repository. Once that was done I had to change some of the nonsensical casing and naming in the Entity list, the model namespace and entities class.

I added a quick WCF Data Service and used LinqPad to prove that everything was working. I then updated the query in my home page to talk to the new entities source. So far, so good. Time to upload to my hosting provider and job done.

Now this is where things got a little pear shaped. Firstly I received the following error.

Unable to find the requested .Net Framework Data Provider. It may not be installed.

OK I figured, I looked at my local project and I had no references to anything MySql, therefore I added the references and set them to copy local, then re-deployed. Same thing.

Next I did a bit more googling.  At this point I should make it clear that I’m using WinHost as my hosting provider, they are really good, they seem to be pretty responsive on their forums and I can mostly find the answers I need (without ever having to ask them directly) when it comes to getting some relatively new tech working on their kit. Therefore I came across this forum post which pointed me to the fact that I had to add this config section in my web.config (remember to change the assembly version to whichever you have downloaded from MySQL).

<configuration>
  <system.data>
    <DbProviderFactories>
      <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.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

Righto, now publish my changes and away we go….almost.

This time I had something like the following error.

System.Security.SecurityException: Security error.

The details mentioned that something was making a request to perform an action that wasn’t allowed under medium trust. A bit more googling and I found this winhost kb article on enabling full-trust. What nice people!

After correcting a few problems with my web.release.config and relocating the MySql password I was up and running.