How do I reference a context in Entityframework?

Asked

Viewed 50 times

0

I am developing a c# API and I use the Entity framework and I need to create an Migration.

My API needs to connect with two databases the internal database and an external database, with this, it was necessary to create two contexts. The problem occurs when I use the command

dotnet ef migration add migration_002

The following error is returned:

More than one Dbcontext was found. Specify which one to use. Use the '-Context' Parameter for Powershell Commands and the '--context' Parameter for dotnet.

I need to select one of several contexts but I can’t select any of them.

2 answers

1


Put -Context (-context if using CLI dotnet) after that the context path, something like:

dotnet ef migrations <COMANDO> --context solução/models/NomeContext
  • Thanks @Rogerio Santos helped a lot!!!

0

I managed to create Migration, it was like this

dotnet ef migrations add migration_001 --context NomeDoContext

Browser other questions tagged

You are not signed in. Login or sign up in order to post.