Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF 4.1 Code First Issue After Upgrade

Okay, so I just upgraded thru NuGet to EF Code First 4.1 and now I get the following build error within my JobSiteContext.cs class:

"The name 'DbDatabase' does not exist in the current context"

Here is my code:

public class JobSiteContext : DbContext
{
    public DbSet<JobSite.Models.Job> Jobs { get; set; }

    public DbSet<JobSite.Models.Location> Locations { get; set; }

    public DbSet<JobSite.Models.Profile> Profiles { get; set; }

    public JobSiteContext()
    {
        // Instructions:
        //  * You can add custom code to this file. Changes will *not* be lost when you re-run the scaffolder.
        //  * If you want to regenerate the file totally, delete it and then re-run the scaffolder.
        //  * You can delete these comments if you wish
        //  * If you want Entity Framework to drop and regenerate your database automatically whenever you 
        //    change your model schema, uncomment the following line:
            DbDatabase.SetInitializer(new DropCreateDatabaseIfModelChanges<JobSiteContext>());
    }
}

Can anyone point me in the right direction?

Thanks Paul

like image 955
Paul Brown Avatar asked Mar 24 '11 16:03

Paul Brown


People also ask

What is EF code First?

Code First allows you to define your model using C# or VB.Net classes. Additional configuration can optionally be performed using attributes on your classes and properties or by using a fluent API.

Whats code First?

In the Code-First approach, you focus on the domain of your application and start creating classes for your domain entity rather than design your database first and then create the classes which match your database design.


1 Answers

It is now just Database.

See here: http://blogs.msdn.com/b/adonet/archive/2011/03/15/ef-4-1-release-candidate-available.aspx

like image 116
Daniel A. White Avatar answered Sep 22 '22 13:09

Daniel A. White