Free .NET development software alternatives

The standard software stack for a .NET developer is

  • OS – desktop Windows
  • IDE – Visual Studio
  • Database – SQL Server

All these components are quite pricey. But there are free alternatives. And with my recent project I decided to use alternative software for development and production in .NET, all totally free.

  • OS – Linux Mint 17 (based on Debian/Ubuntu)
  • IDE – MonoDevelop
  • Database – MySQL Community Edition

monodevelop
Sample solution can be downloaded from here https://github.com/mchudinov/EF6MySQL

MonoDevelop Installation

The last version of Ubuntu (at the time of writing is 14) comes with MonoDevelop IDE version 4. To get the last features it should be upgraded to version 5.x. MonoDevelop 5.x solution and project files are compatible with Visual Studio 2012. Version 5.x is available from so called ppa – Personal Package Archive. Here is the ppa with stabile MonoDevelop https://launchpad.net/~ermshiperete/+archive/ubuntu/monodevelop

To add ppa with the last MonoDevelop stabile version on Linux Mint we can use a program called “Software Sources”.

Mint_software_sources

Or do the following steps in command line and  this should work on any Debian flavour.

1. Add ppa:ermshiperete/monodevelop to your system

sudo add-apt-repository ppa:ermshiperete/monodevelop

2. Pull down the latest list of software from all package archives, including the PPA you just added:

3. Install Mono and MonoDevelop

4. Install certificates
If you get error when installing or updating NuGet packages in MonoDevelop then ssl certificates must be installed. Run the following commands in command line, answer yes when you will be asked to install certificates:

To start MonDevelop run command skript /opt/monodevelop/bin/monodevelop-launcher.sh

Example project with Entity Framework 6 and MySQL

To make EF and MySQL work together we need 3 packages: Entity Framework, MySql.ConnectorNET.Data and MySql.ConnectorNET.Entity. Here is packages.config example

App.config should look like this

One important thing to remember in App.config is that connectionString name attribute must have the same name as Context class, but without “Context”. For example MyDatabaseContext is our context class, the name of the connection string will be MyDatabase. Otherwise EF is looking for a standard SQLEXPRESS database on localhost.

Another important thing is that Context class must have a constructor that calls the parent constructor with connection string name as a parameter.

Enable and start migrations commands in Package Manager Console.
MonoDevelop does not have Package Manager console that can run migrations commands. This can be done in Visual Studio only.

Enable-Migrations
Add-Migration Init
Update-Database

1. Enable-Migrations

2. Add-Migration Init

First time you run Add-Migration Init you get an error message

No MigrationSqlGenerator found for provider ‘MySql.Data.MySqlClient.EF6’. Use the SetSqlGenerator method in the target migrations configuration class to register additional SQL generators.

To solve this the following line must be added to the Configuration.cs in Migrations folder.
SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator());

3. Update-Database

Update-Database command can give us another error:

Specified key was too long; max key length is 767 bytes

767 bytes is the stated prefix limititation for InnoDB tables and if we do not have so long index then error comes from __MigrationHistory tabel, not from data model tables. To check it use -Verbose option with Update-Database command

EF creates a key on (MigrationId,ContextKey) which exceeds the hardcoded maximum key length constraint in MySQL. MigrationId is 255 characters long, and ContextKey is 512 characters long, but each char can occupy more than 1 byte, so mysql is complaining.

The problem is described here http://stackoverflow.com/questions/20832546/entity-framework-with-mysql-and-migrations-failing-because-max-key-length-is-76  The solution is described here http://msdn.microsoft.com/en-us/data/dn456841.aspx. We basically have to tell EF it has to change the way it generates the __MigrationHistory table.

The following file must be added to the solution under Migrations folder to change the way EF generates MigrationHistory table:

And Configuration.cs class must have a new call in constructor
SetHistoryContextFactory("MySql.Data.MySqlClient", (conn, schema) => new MySqlHistoryContext(conn, schema));

Template solution can be downloaded from here https://github.com/mchudinov/EF6MySQL