Mit Entity Framework Core-Migrationen für die Klasse Bibliothek-Projekt

Diese scheinen ein Problem, das bereits behoben, zumindest für die SQLite-Datenbanken.

Meine Lösung besteht aus 3 Projekten:

  1. WPF-Projekt (Standard-startup-Projekt) (.NET Framework 4.7),
  2. "Core" - Projekt halten die view-Modell-und nicht-UI-Zeugs - Klasse-Bibliothek-Projekt (.NET-Standard 2.0)
  3. "Relational" - Projekt halten alle der Entity-Framework-Daten Schicht - ich mag diese getrennt (.NET-Standard 2.0)

Ich habe die folgenden Pakete installiert sind in die wichtigsten WPF-Projekt:

Microsoft.EntityFrameworkCore.Tools
Microsoft.EntityFrameworkCore.Design

Projekte 2 und 3 verwiesen wird, in meinem Haupt-WPF-Projekt. Also im Grunde sollte es genug sein, für die EF zu lösen, die DbContextes.

Es ist jedoch nicht - wie ausgeführt Add-Migration auf mein WPF-Projekt Ergebnisse:

PM> Add-Migration "Initial"
No DbContext was found in assembly 'TestWPFProject'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.

Wechsel zu Projekt 3 als Standard in der Paket-Manager-Konsole führt zu:

PM> Add-Migration "Initial"
Unable to create an object of type 'ClientDbContext'. Add an implementation of 'IDesignTimeDbContextFactory<ClientDataStoreDbContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.

Wie kann ich richtig mit EF-Core-Migrationen mit meiner Klasse-Bibliothek-Projekt-und WPF-Projekt?

InformationsquelleAutor Lucas | 2018-07-03
Schreibe einen Kommentar