I have the following DbContext and I want to migrate it using Entity Framwork
public class TestDbContext: DbContext { public DbSet<State> States { get; set; } public DbSet<StateType> StateTypes { get; set; } public DbSet<Measure> Measures { get; set; } public DbSet<Priority> Priorities { get; set; } public DbSet<Task> Tasks { get; set; } public DbSet<TaskType> TaskTypes { get; set; } public DbSet<Document> Documents { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string databaseFilePath = "test.db"; try { databaseFilePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, databaseFilePath); } catch (InvalidOperationException) { } optionsBuilder.UseSqlite($"Data source={databaseFilePath}"); } protected override void OnModelCreating(ModelBuilder modelBuilder) { }
I ran the instruction
enable-migrations -ContextTypeName TestData.TestDbContext
in the package manager console to create the configuration. But the generation has compilation errors, because the following namespaces / classes cannot be found:
using System.Data.Entity; using System.Data.Entity.Migrations; DbMigrationsConfiguration
.
namespace TestData.Migrations { using System; using System.Data.Entity; using System.Data.Entity.Migrations; using System.Linq; internal sealed class Configuration : DbMigrationsConfiguration<TestDatas.TestDbContext> { public Configuration() { AutomaticMigrationsEnabled = false; } protected override void Seed(TestDatas.TestDbContext context) {
Any decisions on how the configuration can compile to add migration?
source share