3

I'm using MySQL .NET Connector in my ASP.NET MVC project. The connection works fine.

However, after creating a ADO.NET Data Model from my MySQL database (with "Update Model from Database") for the first time, each time I change the database in any way (add/remove tables/properties) and choose "Update Model from Database" again, the .edmx file (designer) updates, but the Entities don't.

How can I update everything? I tried to delete the table from the designer and going through "Update Model from Database" again, it adds the tables to the designer, but the Entities never change.

Is there any way to do this properly?

Walkthrough through the problem:

  • Add table users to designer

  • Add column phone to database table users and refresh Server Explorer, making sure the column is there.

  • Refresh the Data Model, by going to "Update Model from Database" and choosing users table in Refresh tab.

  • The column phone is added to the designer. Everything seems be working fine.

  • Going to the code, the property phone is not in the Entity class.

Gaui
  • 8,723
  • 16
  • 64
  • 91
  • 2
    Is your edmx file by any chance nested in a folder and you don't have VS 2011 Update 1? It seems to me this is a bug that was fixed in VS 2011 Update 1 where the code would not be generated if the edmx file is in a nested folder. The work around is to right click the tt file and select "Run Custom Tool". Relevant links: http://stackoverflow.com/questions/12734333/entity-framework-5-update-model-from-database-does-not-generate-table-class/12736291#12736291 and https://entityframework.codeplex.com/workitem/453 – Pawel May 29 '13 at 18:16
  • Yes that solved the problem. Could you answer the question and I'll mark your answer as the accepted answer? – Gaui May 29 '13 at 18:37

1 Answers1

4

@Pawel answered this question, but I want to add an accepted answer.

This is a known bug in Visual Studio 2012:

http://entityframework.codeplex.com/workitem/453

This can be fixed with Visual Studio 2012 Update:

http://www.microsoft.com/en-us/download/details.aspx?id=38188

Gaui
  • 8,723
  • 16
  • 64
  • 91