0

When working in Ruby (specifically, in Rails), I can automatically run my tests using a testing database, and also choose easily between a development or production database. Still new to Entity Framework (WPF), but it seems less than simple.

My Entity assembly has an App.Config file that holds a reference to the database, and I need to copy this App.Config file to all runnable projects (e.g. questions 1113361 and 2233897).

If I use Test->Database Test Configuration without explicitly copying App.Config from my EF project, I get

System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

which is the same as if I have a missing or different App.Config file.

Strangely even if I do change all the connection stings in my Entity project and testing project to the same database, I still get that error.

Is there a step I'm missing when telling Visual Studio (2010 Ultimate) that I want my tests to run using a different testing database, or is this just not supported with EF 4?

Also, Is there some way to change database context other than copying App.Config files back and forth? Seems like a serious way to ignore separation of concerns if not, so I think I'm missing something.

Community
  • 1
  • 1
JohnMetta
  • 18,782
  • 5
  • 31
  • 57
  • I usually have a link to prod and a link to test/dev in my .config file, and then just comment out the connection I don't want to use. – E.J. Brennan Dec 31 '10 at 23:17

1 Answers1

1

Strangely, as I was playing around after doing this, it started working. Somebody might comment on this, but it looks like I was using Test->Database Test Configuration at the wrong time.

To wit:

Clean project, no App.Config, use Test->Database Test Configuration to set the test database. It generates an app.config (lowercase, notably). You get an error. Even if you check all the connection strings (weird)

Clean project, first copy the App.Config from from you Entity project. Now when you use Test->Database Test Configuration, it will populate the App.Config that you copied, and it works.

I imagine it was some issue I was creating when copying the connection strings.

I've also confirmed that this works with my Entity project using a "Main" database while my testing project uses a "Test" database.

Wonder if someone can confirm/clarify this?

JohnMetta
  • 18,782
  • 5
  • 31
  • 57