none
change connection string without refreshing / updating the edmx RRS feed

  • Question

  • I have a desktop application, which is already deployed with clients, i need to change the database point of the edmx file.

    Everytime i try to change the connection string for edmx file, it requires to be updated through visual studio and hence a new build is required, i want my edmx file to point to the new connection automatically.

    Is there any solution to update the edmx without refreshing it?

    Thanks.

    Tuesday, December 20, 2011 8:16 AM

Answers

  • Hi Bharti_P;

    To change the database connection string you can modify it in the app.config file. As long as the new database that it points to has the same schema all should be well.

    // Sample connection string for EF in app.config, change only the parts  that are bolded
    <connectionStrings>
        <add name="AdventureWorksEntities"
             connectionString="metadata=.\AdventureWorks.csdl|.\AdventureWorks.ssdl|.\AdventureWorks.msl;
             provider=System.Data.SqlClient;provider connection string='Data Source=localhost;
             Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60;
             multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />
    </connectionStrings>

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Proposed as answer by Tyler_A Wednesday, December 21, 2011 1:44 AM
    • Marked as answer by Bharti_P Wednesday, December 21, 2011 6:40 AM
    Tuesday, December 20, 2011 2:45 PM
  • Changing only connection string in the config file is not enough. The mapping (of edmx objects and database table/view objects) needs to be done again, so it becomes like creating a new edmx file. As a shortcut, i changed the ssdl file manually to get it mapped.


    May be my question was wrong, i wanted to change the schema name as well....
    • Marked as answer by Bharti_P Wednesday, December 21, 2011 6:40 AM
    • Edited by Bharti_P Wednesday, December 21, 2011 8:38 AM
    Wednesday, December 21, 2011 6:38 AM

All replies

  • Hi Bharti_P;

    To change the database connection string you can modify it in the app.config file. As long as the new database that it points to has the same schema all should be well.

    // Sample connection string for EF in app.config, change only the parts  that are bolded
    <connectionStrings>
        <add name="AdventureWorksEntities"
             connectionString="metadata=.\AdventureWorks.csdl|.\AdventureWorks.ssdl|.\AdventureWorks.msl;
             provider=System.Data.SqlClient;provider connection string='Data Source=localhost;
             Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60;
             multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />
    </connectionStrings>

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Proposed as answer by Tyler_A Wednesday, December 21, 2011 1:44 AM
    • Marked as answer by Bharti_P Wednesday, December 21, 2011 6:40 AM
    Tuesday, December 20, 2011 2:45 PM
  • Changing only connection string in the config file is not enough. The mapping (of edmx objects and database table/view objects) needs to be done again, so it becomes like creating a new edmx file. As a shortcut, i changed the ssdl file manually to get it mapped.


    May be my question was wrong, i wanted to change the schema name as well....
    • Marked as answer by Bharti_P Wednesday, December 21, 2011 6:40 AM
    • Edited by Bharti_P Wednesday, December 21, 2011 8:38 AM
    Wednesday, December 21, 2011 6:38 AM