3

I'm trying out Code First. I've two seperate contexts using the same database.

My problem is how to use the databaseinitializers.

If I use a initializer that drops the database, it only works for the first context. Then I initialize the secont context, and that initializer delets the tables creatde by the first initializer.

Any advices who to solve this?

1 Answer 1

2

In case of code first you should not have two different context types for the same database. You should have only one - your use case is not expected in code first scenario.

To solve your problem you must simply use initializer only for one context type and make sure that it is always used first.

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

2 Comments

Ok, thank you. I was just curious if I have missed some smart way to use multiple contexts at the same time.
What about the case of a separate context for Identity 2.0?

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.