I’ve implemented WCF service using Entity Framework in a 3-Tier solution. I got it working, but what is puzzling me is why did I have to copy connection string ( specified in configuration file C1, which is used by Entity Framework to retrieve schema information from a database) into configuration file C2 used WCF service? Namelly, if I don’t copy the connection string, then I get:
FaultException: The specified named connection is either not found in the confiuration,
not intended to be used with the EntityClient provider, or not valid.
So it seems that C1‘s connection string is used by Entity Framework at design time, while during runtime connection string specified in C2 is used instead to connect to the database? Why?
Thank you
The connection string always comes from the config file for the executing assembly, unless you specify otherwise. The reason is obvious: Two different executables referencing the same data DLL might want to use different physical DBs.
At design time, there is no executing assembly. So the config file for the project containing the EDMX is used.