Database First - MVC

3

I've always worked with code first and using only one database. However, I need to work with an application with two databases already created.

To work with two databases, I created this:

Passing:

Receiving:

Now, how can I easily work to reuse existing banks, including views?

    
asked by anonymous 16.12.2015 / 13:41

1 answer

2

For read-only contexts, add the following in the context class:

public override int SaveChanges()
{
    throw new AccessViolationException(
         "Contexto é somente leitura.");
}

public override async Task<int> SaveChanges()
{
    throw new AccessViolationException(
         "Contexto é somente leitura.");
}

This ensures that the context can not make changes to the database.

On the plus side, I think you're already using it accordingly.

    
16.12.2015 / 16:39