Fixing bugs in MySQL Connector/NET – or how to make code first migrations work

Hello folks – just a quick post!

I finally found the time to publish a workaround I wrote back in May this year. I was hacking a fully automatic irrigation system (garden stuff you know ^^) and because I had to do that really quickly (before leaving for vacation) I decided go the route of a known framework: OWIN, ASP.NET WebAPI 2, NOWIN (as a host), Identity 2.0, EntityFramework, MariaDB, a good HTML5 stack… etc…

Well mostly a known framework; I had to run on a Raspberry and Microsoft wasn’t quite as ready with Windows 10 IoT as I’d needed it… So it was a quick decision to stick with Raspbian and Mono. Which by the way work out great. At the time of writing my little application has over 140 days of uptime! – Yay –

I’ll probably write more about the whole project in the next months!

Anyhow I faced the problem that the MySQL Connector/NET is *still* (I posted the bug on November 7th 2014 – Bug Ticket: #74726 EF migrations fail on long foreign keys) having issues with code first migrations, long entity names and foreign keys… and as I really lost any confidence that ****** is going to fix that any-time soon I decided to do it on my own…

Continue reading

ASP.NET Identity 2.0 and MariaDB

…I finally made it: ASP.NET Identity 2.0 running with MariaDB! It was more difficult than I expected it to be. I’ve been using EntityFramework with MySQL successfully in my day-time job for over two years now. As I was starting a small toy project at home last week I decided to go the easy route: ASP.NET Web API 2 running in an OWIN application. That was the perfect opportunity for giving ASP.NET Identity 2.0 a shot – instead of rolling my own authentication framework.

I still believe that this choice isn’t bad at all, but I underestimated the cost of getting it to run in a heterogeneous environment (read: not everything is Microsoft technology).

Surprisingly (to me – but hey!) Microsoft is providing an example of how to use MySQL and EntityFramework 6 as a storage provider for ASP.NET Identity 2.0. Sadly the example isn’t working out of the box – at least not in my setup. One aspect is that when they wrote the tutorial the MySQL Connector/NET wasn’t supporting EF Code-first migrations as well as it does nowadays. The second issue was the primary keys in the ASP.NET Identity tables being too long for MySQL.

Continue reading