I am trying to create a small ASP.NET vNext WebAPI + AngularJS + Entity Framework project. But obviously a lot has changed in EF7, so I am experiencing the following issues:
I modified project.json as follows:
"dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta1", "EntityFramework": "7.0.0-beta1", "EntityFramework.SqlServer": "7.0.0-beta1", "EntityFramework.Commands": "7.0.0-beta1", "Microsoft.AspNet.Mvc": "6.0.0-beta1", "Microsoft.AspNet.Diagnostics": "1.0.0-beta1", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta1"
In my DataContext class, I am trying to do the following:
using System; using Project1.Models; using Microsoft.Data.Entity; namespace Project1.DataAccess { public class DataContext { public DbSet<Website> Websites { get; set; } public DataContext() { Microsoft.Data.Entity.Infrastructure.Database.SetInitializer(new DropCreateDatabaseIfModelChanges<DataContext>());
}
First of all: Why did the System.Data.Entity namespace change to Microsoft.Data.Entity ? I can't find anything about this change in any Microsoft MSDN article!
Second: the whole Database.SetInitializer no longer works. He recommends using the Microsoft.Data.Entity.Infrastructure namespace, but this database class does not contain the SetInitializer method.
source share