1
votes

I am trying to use the MySQL Database with the Entity Framework Version 4.1.0.0 and Mono 2.11.4 in a ASP.NET MVC 3 Project.

On my Local Windows system everything works great but when I publish it to my Ubuntu 12.04 LTS System I get a lot of errors.

First I get:

Could not load type 'System.Data.Entity.Infrastructure.DbUpdateException' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

when I press F5 I get different errors every time the page refreshes:

  • Could not load type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

  • Could not load type 'System.Data.Entity.Infrastructure.DbCompiledModel' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

  • Could not load type 'System.Data.Entity.Infrastructure.ReplacementDbQueryWrapper`1[TElement]' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

  • Could not load type 'MySql.Data.VisualStudio.Editors.SqlEditor' from assembly 'MySql.VisualStudio, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.

  • Could not load type 'MySql.Data.VisualStudio.WebConfig.WebConfigDlg' from assembly 'MySql.VisualStudio, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.

  • A type load exception has occurred.

The last error occurred when I try to use the database with this code:

using (var db = new DefaultContext())
{
    db.Persons.Add(new Person() { Name = "hallo", Address = "bllaaa" });
    db.SaveChanges();

    var persons = db.Persons.ToList();
    return View(persons);
}

Did anybody have a similar problem and solved it? I do not know what to do.

P.S.: I use Code First Migration

2

2 Answers

0
votes

From my understanding, Mono is bundling the open source version of Entity Framework, which is essentially yet-to-be-released v6.

http://weblogs.asp.net/scottgu/archive/2012/07/19/entity-framework-and-open-source.aspx

So it would seem you can't target EF v4.x, since the code has likely undergone major changes. Although, if you discover that the seemingly missing types are still there, you could attempt to work around the issue with an assembly redirect (just search for bindingRedirect).

0
votes

I know why this happend. I installed the mono-fastcgi-server4 through apt-get after i installed mono from source. So i had 2 mono versions installed and the older one was active. (2.10.8)

And the Entity Framework seems totally useless to me because only the new EF6 works with a database but there arent any provider who suppot EF6 and work with mono.