Reputation: 732
I can't find DataBase
in System.Data.Entity
.
Any one know why?
Thank you.
Upvotes: 18
Views: 16678
Reputation: 1
Just update your Entity Framework to do that just right click on the solution and select "Manage NuGet Package" and search with "EntityFramework". install latest version ( 6.1.3 or ) or use " NuGet package console" enter image description here
Upvotes: 0
Reputation: 1
On my version, Entity Framework 4.1.10715.0', System.Data.Entity.Database
is a namespace and not a class. DbDatabase
IS a class in that namespace and it contains the SeInitializer
method. What a PITA to find when everything I've read contradicts this.
I had to use the following to get the Steven Sanderson demo to remake my database.
System.Data.Entity.Database.DbDatabase.SetInitializer(
new System.Data.Entity.Database.DropCreateDatabaseIfModelChanges<Mvc3ScaffoldDemo.Models.Mvc3ScaffoldDemoContext>());
Upvotes: 0
Reputation: 32179
At a guess, you upgraded from Enterprise Library 4 CTP5 to Enterprise Library 4.1.
The namespaces changed a little and you will now find the classes you need in different namespaces. As shown in Kasper Skov's answer here, the DbDatabase
class is now in System.Data.Entity
and is renamed to Database
.
I haven't yet worked out where IConfigurationConvention has moved to as System.Data.Entity.ModelConfiguration.Conventions.Configuration
is another defunct namespace.
Upvotes: 1
Reputation: 147
I have same problem. Daz and Darin's answer gave me some clues.
In CTP, the class name is called "DbDatabase" in namespace System.Data.Entity.Database.
But in my version which is EF 4.1, the class is called "Database" and is in System.Data.Entity. System.Data.Entity.Database namespace is gone at least in EF4.1
Upvotes: 3
Reputation: 2014
You dont have to import System.Data.Entity.Database
. The System.Data.Entity
is enough.
Use Database.SetInitializer
instead of DbDatabase.SetInitializer
.
If you missed it it, the class is called Database without "Db"
Upvotes: 22
Reputation: 1038930
You need to reference the EntityFramework.dll
assembly which is where the Database class is declared. You could install it from the corresponding NuGet package.
Upvotes: 8