I have several projects and each project has a context. I would like to know how to use Migrations to update and generate only one database of these various contexts?
I have several projects and each project has a context. I would like to know how to use Migrations to update and generate only one database of these various contexts?
Multiple contexts are useful for structuring / isolating project areas; obviously this increases complexity. Then you can create each context pointing to the same base and get the job done normally.
An advantage of EF6 is that it has been released with functionality to support multiple contexts . I found some answers to your problem:
Tutorial:
Answer:
You create only ONE connection, and use it for your project. So:
Context contexto = new Context(); <----(cria uma conexao)
ProjetoRepository nomeRepositorio = new ProjetoRepository (contexto);
(ProjetoRepository usando a conexao "contexto ")
OutroProjetoRepository nomeOutroReposito = new OutroProjetoRepository (contexto);
(OutroProjetoRepository usando a mesma conexao "contexto ")
As each context is a completely different instance I believe this is not possible. Unless you create a context that manages all contexts and encompasses one.