none
Connect Entity Framework to remote server database ? RRS feed

  • Question

  • Hello,

     

    How can I connect Entity Framework to a remote database ?

    If possible.

     

     

    Thank you for your help.

    Sunday, January 1, 2012 1:58 PM

Answers

  • Hi ThomasMSN;

    Once you created the EF model in your project and now want to use a different server with the same database schema what you need to do is open the projects App.config if a desktop application or the web.config if a web application. you will find a connection string node, <connectionStrings> ... </connectionStrings>, in that node there is a section called, provider connection string, the first parameter in that section is call, Data Source=, change the source of the database to point to the new location by supplying the IP address or http//... URL to the database. That is all that is needed.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Sunday, January 1, 2012 2:32 PM

All replies

  • Hi ThomasMSN;

    Once you created the EF model in your project and now want to use a different server with the same database schema what you need to do is open the projects App.config if a desktop application or the web.config if a web application. you will find a connection string node, <connectionStrings> ... </connectionStrings>, in that node there is a section called, provider connection string, the first parameter in that section is call, Data Source=, change the source of the database to point to the new location by supplying the IP address or http//... URL to the database. That is all that is needed.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Sunday, January 1, 2012 2:32 PM
  • Can this be done starting with a remote database? If not can I just copy my remote database locally and then change the connection string as you mentioned?

    Thank you in advance for you time.

    Tuesday, November 6, 2012 2:12 PM
  •   

    To your question, "Can this be done starting with a remote database?", Yes. In Visual Studio open the Server Explorer and crate a connection to the remote server. Then when you create the EF model it will use the connection string to the DB you are working with.

    If you have any other questions on this subject please open a new question.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Tuesday, November 6, 2012 2:22 PM