Frage

Ich bin gerade mit EF 5 an Bord gekommen und nutze ihr Code-First-Migrations-Tool, aber ich scheine einen Fehler zu bekommen, wenn ich versuche, Migrationen zu aktivieren.

i Geben Sie Enable-Migrations in die Paketmanager-Konsole ein und dann sagt es

Keine Klassen, die im dbcontext im aktuellen Projekt gefunden werden.
Bearbeiten Sie die generierte Konfigurationsklasse, um den Kontext anzugeben, um Migrationen für zu aktivieren.
Code Erste Migrationen aktiviert für das Projekt myApp.mvcui.

Es erstellt dann einen Migrationsordner und eine Konfigurationsklasse in meinem MVCUI-Projekt.Ding ist, mein Dbcontext lebt in einem Klassenbibliotheksprojekt namens myapp.domain.Es sollte alles in diesem Projekt tun, und sollte kein Problem haben, meinen dbcontext zu finden.

War es hilfreich?

Lösung

Oh wow, nevermind. I'm dumb.

In the Nuget package manager console there is a dropdown menu at the top labeled "Default Project:". Make sure you set that to the project you want to run the command against.

Hopefully this helps someone else avoid my embarrassing mistake.

Andere Tipps

There are actually 3 ways to make Nuget commands run in a specific project:

  1. [Package Manager Console] Set the active project in the dropdown at the top of the console toolwindow
  2. [Package Manager Console] Look for a parameter to specify the project. For some cmdlets I've seen -ProjectName and some use -Project
  3. [Solution Explorer] Right-click the project you want, and use the graphical package manager window (Manage NuGet Packages...).
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top