share connectionstrings with multiple projects in

2019-06-19 12:59发布

问题:

I have multiple projects in the same solution. I would like them to share the same connectionStrings so that I don't have to change the this in multiple places.

In my web configs I have

<connectionStrings  configSource="bin/connectionStrings.config" />

and then I have added a file as a link to my "connectionsStrings.config" which sits at the solution level.

I have changed the properties so that the "Copy to Output Directory" is "Copy always" and the "Build Action" is "Content"

But I get the following error:

 The configSource attribute must be a relative physical path, so the '/' character is not allowed.

I am not sure how to get around this issue, any help would be great.

Cheers

回答1:

I fixed this by changing

<connectionStrings  configSource="bin/connectionStrings.config" />

to

<connectionStrings  configSource="bin\connectionStrings.config" />

:/