Is RecreateDatabaseIfModelChanges available in WPF?
I'm trying out Entity Framework Code First. I can't seem to find the assembly/namespace to use for RecreateDatabaseIfModelChanges
in WPF 4.0. Is this an ASP.NET-only feature? If not, what assembly should I reference?
Here's my code:
using System;
using System.Data.Entity;
using System.Windows;
using CodeFirstTester.Models;
namespace CodeFirstTester
{
public partial class App : Application
{
static App()
{
// this fails:
Database.SetInitializer(new RecreateDatabaseIfModelChanges<NerdDinners>());
// The type or namespace name 'RecreateDatabaseIfModelChanges'
// could not be found (are you missing a using directive or
// an assembly reference?)
using (var nerdDinners = new NerdDinners())
{
var dinner =开发者_JAVA技巧 new Dinner()
{
Title = "Party at Scott's House",
EventDate = DateTime.Parse("12/31/2010"),
Address = "Building 40",
HostedBy = "scottgu@microsoft.com"
};
nerdDinners.Dinners.Add(dinner);
nerdDinners.SaveChanges();
}
}
}
}
The initializer is called DropCreateDatabaseIfModelChanges
. It can be found in EntityFramework.dll (EF 4.1) in System.Data.Entity
namespace.
精彩评论