I'm trying to create a little ASP.NET vNext WebAPI + AngularJS + Entity Framework project. But obviously, a lot changed in EF7 so I am experiencing the following issues:
I changed the project.json
as following:
"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 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>());
//Database.SetInitializer(new DropCreateDatabaseAlways<DataContext>());
}
}
}
}
First of all: Why has the namespace System.Data.Entity
changed to Microsoft.Data.Entity
? I cannot find anything about this change in any microsoft msdn article!!
Second: The whole Database.SetInitializer
doesn't work anymore. It recommends to use the Microsoft.Data.Entity.Infrastructure
namespace but that Database class doesn't contain a SetInitializer
method.