0

I have a large number of tables in my database and I want to create multiple Entity Data Models. I want them all to reference the same connection string in either my web.config or app.config.

right now, when I go through the wizard in vs2012 to create each model, it seems to create a new configuration entry in my app.config with it's own credentails. Maybe somehow I'm not picking the right options?

What is a clean way to do this so I just have one connection string that is used for all my Entity Data Models?enter image description here

2 Answers 2

1

When you are developing using visual studio each model needs it's own connection string.

But your code does not need to use these connection strings. There is a constructor for the Context that allows you to send in a connection string. If you use this, you could have a single connection string in your app settings, which is used for all Contexts (models).

Sign up to request clarification or add additional context in comments.

1 Comment

that makes a lot of sense. I'll go that path.
0

Unfortunately each Entity data model (EDMX file) must have its own connection string because the connection string references XML files created from that model (that are those csdl, ssdl and msl things referenced in the connection string). If you want to have just one DB connection string you will have to build entity connection strings in your application.

1 Comment

Thanks Ladislav. Can you point me to an example of that? I don't want to give up using the visual studio model builder and am hoping I can continue to use that. I've always been afraid of the csdl, ssdl and msl files an am hoping to avoid those like I do IL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.