Tuesday, October 30, 2012

Workaround for importing Foreign Keys in Entity Framework 4 in VS 2010 with MySql

Well this was another BIG issue I faced when designing database for my application.
I decided to use Entity Framework 4 for ORM and C# as my development language and Ms Sql Server 2008 as my backend.
But then there some issues with its license so I wished to switch to MySql as my DB.After designing the whole databse from scratch in MySql I found that the EF4 was not generating foreing keys and the navigation properties in its EDMX i.e its data model.
I was really frustrated after desinging the whole Db from scartch and then it was not working in EF4.
As usual I googled it and no help from ther also....I did not found any proper solution for that.
Then as aiming arrow in the dark I thought of trying MySql Migration ToolKit and BINGO.
so the Workaround......
Go to Mysql Migration Toolkit
Import the database from MsSql Server into Migration Toolkit
Then from Visual Studio import the Model in EF4 as usual.
Hope this works for you guys also....!