Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have a asp.net mvc 5.1 solution with 3 projects in it shown by the image below:

Folder structure of my solution in visual studio

I have Ninject, FakeitEasy, MySql nuget packages installed in my project and I am using the repository pattern in my project so I have an IRepository generic interface, IDbContext interface and a concrete repository generic class (all this is in the AccountManager.Domain). With everything Ninject and mysql all setup, I built the solution and so far so good until I tried to add a controller using the scaffolding options given with Entity Framework and I get an error saying:

Unable to retrieve metadata for 'AccountManager.Domain.Entities.Bank' using the same DbCompiledModel to create contexts against different types of Database servers is not supported. Instead create a separate DbCompiledModel for each type of server being used.

I saw this when I was head banging with sqlite and EF code first. What does it mean again? Anyone see some perspective I don't?

share|improve this question
    
There is no good support for CodeFirst approach with MySql and Oracle AFAIK. I am working on a project with MySql and EF using DatabaseFirst approach and it works fine. – lbrahim Nov 27 '14 at 12:17
    
I created a simple mvc 5 web app and brought in mysql 6.9.5 (EF, webconnect and mysql.data) and created 3 simple model classes decorated my context class with mysqlEFConfiguration which builds successfully but still cannot scaffold a controller. Back in version 6.8.3 this was no problem at all. Wonder what happened? Will keep plugging away to see – Eagletrophy Nov 27 '14 at 14:37
    
Funny thing is I removed all mysql nuget packages and decided to use local and it works beautifully. I wonder if the problem isn't mysql and it's .net connector... Trying to get to the bottom of this – Eagletrophy Nov 27 '14 at 20:28
up vote 0 down vote accepted

I have been plugging away at this annoyance for a while and I found that its something that is just simple. Decorating my context class with this mysqlefconfig like so:

[DbConfigurationType(typeof(MySqlEFConfiguration))]

helps the context to make the necessary adjustments to the migration table EF creates automatically so it works with MySql is the reason why my controllers didn't scaffold at all. I got the idea to try comment this out from http://stackoverflow.com/users/3671905/yurko and the scaffolding worked gorgeously.

Only thing to note is that after you finished your scaffolding you need to uncomment it so that all the MySQL peculiarities required by EF should be restored. I prefer attribute configuration than creating files and editing infrastructure files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.