Sunday, April 17, 2011

The type or namespace name 'ModelBuilder' does not exist

If you encountered this error:


The type or namespace name 'ModelBuilder' does not exist in the namespace 'System.Data.Entity.ModelConfiguration' (are you missing an assembly reference?)

Just change...

System.Data.Entity.ModelConfiguration.ModelBuilder modelBuilder

...to:

System.Data.Entity.DbModelBuilder modelBuilder

1 comment:

  1. using EF 4.1 I get this code but the error still exists:

    //------------------------------------------------------------------------------
    //
    // This code was generated from a template.
    //
    // Manual changes to this file may cause unexpected behavior in your application.
    // Manual changes to this file will be overwritten if the code is regenerated.
    //
    //------------------------------------------------------------------------------

    namespace MvcApplication1.Models
    {
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;

    public partial class BookingSystemEntities : DbContext
    {
    public BookingSystemEntities()
    : base("name=BookingSystemEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
    throw new UnintentionalCodeFirstException();
    }

    public DbSet tbTrades { get; set; }
    }
    }

    ReplyDelete