EF port for universal Windows platform

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) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. Eg // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // } } } 

Any decisions on how the configuration can compile to add migration?

+5
source share
1 answer

This EF7 documentation may be helpful.

I tested, DbContext should use this link:

 using Microsoft.Data.Entity; 

and using System.Data.Entity.Migrations; must also be changed to

 using Microsoft.Data.Entity.Migrations; 
+2
source

Source: https://habr.com/ru/post/1237088/


All Articles