0

I'm trying to use EF6 in my project and I've got two databases I'm trying to interact with. My app.config has connection strings for both, and I have two DbContext classes that pass in the app.config's key for the corresponding connection string. One context:

public LogProcessorContext() : base("LogProcessorDb")
    {
    }

    public DbSet<LogFile> LogFiles { get; set; }

the other context:

public MessageTrackingContext() : base("MessageTrackingDb")
    {

    }

    public DbSet<JournalLog> JournalLogs { get; set; }

but when I add the migration using add-migration NewBranch and update the db, a log file table gets added to the message tracking db (the wrong one), and the journallogs table doesn't get added at all. If anyone has any experience getting ef to play nice with multiple db/contexts, i'm all ears. I'm sure its just some simple mistake I'm making.

btw,

"LogProcessorDb"

and

"MessageTrackingDb"

are the keys in my app.config for my connection strings.

Thanks!

will
  • 837
  • 3
  • 11
  • 24
  • We'll need the migration command you are running – Camilo Terevinto Feb 20 '19 at 14:20
  • I just used add-migration and named it. – will Feb 20 '19 at 14:23
  • *Show us* the migration command. It's hard to help when we can't see what you did. –  Feb 20 '19 at 14:25
  • I'm sorry, this is my first foray into EF. I don't know what you mean. I literally made sure my models were what I wanted in the db and entered "add-migration NewBranch" into the package manager console. are you looking for the migration it created? – will Feb 20 '19 at 14:29
  • 1
    Possible duplicate of [How do I enable EF migrations for multiple contexts to separate databases?](https://stackoverflow.com/questions/13469881/how-do-i-enable-ef-migrations-for-multiple-contexts-to-separate-databases) – Owen Pauling Feb 20 '19 at 14:33
  • The reason we ask for the *exact* command you entered is the command has a lot of options, which you might or might not be using. It's better when we're all on the same page and not making assumptions. It helps us help you. That's all. –  Feb 20 '19 at 14:34
  • Does this help? https://stackoverflow.com/questions/13469881/how-do-i-enable-ef-migrations-for-multiple-contexts-to-separate-databases –  Feb 20 '19 at 14:39

0 Answers0