Multiple contexts Migrations Entity Framework

15

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?

    
asked by anonymous 26.02.2015 / 06:40

4 answers

1

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.

    
20.12.2017 / 20:50
-1

An advantage of EF6 is that it has been released with functionality to support multiple contexts . I found some answers to your problem:

Tutorial:

link

Answer:

link

    
04.03.2016 / 11:51
-2

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 ")
    
13.03.2017 / 14:43
-4

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.

    
26.02.2015 / 23:05