none
How to: Update an .edmx File when the Database Location Changes (Entity Data Model Tools) RRS feed

  • Question

  • First I read all these useful information on MSDN documentation about Modeling task in Entity Framework. I found the question about How to: Update an .edmx File when the Database Changes (Entity Data Model Tools). My question is about How to: Update an .edmx File when the Database Location Changes (Entity Data Model Tools). When I do a migration of my database.

    For technical reason I need to move my dev database from my local computer to a professional server. I use MySQL. The transfer of the database has been done without any problem. The name of my schema changed from "MyProject" on my local computer to "MyProjectDatabase" on the server.

    I also modified the connection string in my app.config.

         connectionString="metadata=res://*/MyProjectModel.csdl|res://*/MyProjectModel.ssdl|res://*/MyProjectModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=xx-xxxx-azure-xxx-x.cloudapp.net;user id=xxxxxxxx;password=xxxxxxxx;database=MyProjectDatabase"" providerName="System.Data.EntityClient" />

    Now when I try to validate or update my model from database through Visual Studio the system want to recreate/add all my tables. I see nothing in my refresh tab. What should I do to tell my edmx file that my database is the same and he need to refresh, not to add tables?


    • Edited by B413 Thursday, October 30, 2014 9:11 AM
    Thursday, October 30, 2014 2:17 AM

Answers

  • Hello B413,

    >>My question is about How to: Update an .edmx File when the Database Connection Changes (Entity Data Model Tools). When I do a migration of my database.

    If you are just moving the database from one place to another place, you just need to modify the data source value (and database if you change the database name):

    <add name="DFDBEntities" connectionString="metadata=res://*/DFDBModel.csdl|res://*/DFDBModel.ssdl|res://*/DFDBModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=YourNewDataSource;initial catalog=XXX;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

    >> The name of my schema changed from "MyProject" on my local computer to "MyProjectDatabase" on the server.

    If you move these tables from one schema to another one, if you want to use the legacy model, then you need to open your .edmx file with the XML editor and find all the original one and replace them with the new one. Of course, you could just delete all the table and recreate them from the new schema.

    >> I also modified the connection string in my app.config.

    The value of XXX.csdl/ssdl/msl should be the same with your model name and we do not need to modify it, please have a try change them back to its original value.

    Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 30, 2014 7:54 AM
    Moderator