1

I have an .NET MVC application which utilizes entity framework and a 3rd party provider to interact with an Oracle database. I need to be able to choose among two connection strings based on who is using the application. The 3rd party provider assumes it will find a connection string in the app.config of the project in which in the entity data model resides which corresponds in name to the Entity Container Name.

The question: How can I set the connection string such that it will be present? If I use the EntityConnectionStringBuilder as outlined here before any calls are made to the database will it be equivalent to setting the connection string in app.config? IE will the Entity Framework stuff find what it is looking for?

Robaticus
  • 22,857
  • 5
  • 54
  • 63
jollyRoger
  • 11
  • 2
  • You should be able to setup a test case where you can run through this using the EntityConnectionStringBuilder with two separate connection strings. Experiment a little ;) – thaBadDawg Jan 24 '11 at 18:07

2 Answers2

1

Yes. You already have your answer.

John Farrell
  • 24,673
  • 10
  • 77
  • 110
1

If you don't need to build the connection string dynamically, i.e. you know you are working with 2 connection strings and each string doesn't change at runtime, just which one is used will change, then you do not need to worry about using the EntityConnectionStringBuilder class, you should be able to simply pass in the desired connection string on the constructor of your database context.

Brian Ball
  • 12,268
  • 3
  • 40
  • 51
  • Right! Whenever I instantiate the data context anywhere I can just initialize it with the connection string that should be used. Thanks! – jollyRoger Jan 24 '11 at 18:39