2

I'm just getting started with VS2012 and EF5 and am writing an app that needs to be able to connect to one of a variety of databases with identical schema. MSDN shows a DbContext constructor that takes a connection string as a parameter, but for some reason my generated context only includes and empty constructor.

If I manually add the constructor to the generated class then it works fine, but I don't want to have to do this every time after updating my model.

Anyone ever run into this before?

1
  • 2
    You can add a partial class for the derived DbContext class where you would add the ctor with the parameter. This way you would not have to re-add the ctor each time the code is generated. Commented Jan 4, 2013 at 22:22

1 Answer 1

2

You can add a partial class for the derived DbContext class where you would add the ctor with the parameter. This way you would not have to re-add the ctor each time the code is re-generated.

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

Comments

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.