Reputation: 4999
I am maintaining an existing (and working) C# project which uses Entity Framewwork 6
to do the ORM. Now I need to migrate the database from MySQL
to SQL Server
. So far I have been able to make the program compile by modifying the .edmx
file (For example, I changed the Provider
from MySql.Data.MySqlClient
to System.Data.SqlClient
and ProviderManifestToken
from 5.6
to 2008
. Also I needed to change some data types in the ssdl content, for example from double to float).
Now when I run a simple LINQ
query against the ObjectContext
-derived context like this:
var query = from data in context.user select data;
var users = query.ToArray();
It gives me the exception "Invalid object name 'MYDBNAME.user'."
Apparently a ".dbo" is missing, i.e., the translated SQL query should be
select * from MYDBNAME.dbo.user
instead of
select * from MYDBNAME.user
But I am not sure how I can instruct EF to add the ".dbo". Is there some configuration/option to do that?
Upvotes: 1
Views: 1177
Reputation: 149
It's very simple and easy approach You have to follow the below steps I hope it will work in your case.
You have to build all your schema in MSSQL Server from that MYSQL
Once you have completed your Database Schema in MSSQL Server
Then you have to follow the database first approach in Entity Framework and It will automatically build all you models and DB context from the database.
How to generate DB models and context (Database First Approach) Data Base First EF
Then You will be able to apply Linq on the database and queries. Thanks
Upvotes: 1