日期:2014-05-17  浏览次数:20873 次

ModelBuilder 的命名空间是哪个?
我百度了下也没有找到


错误 1 未能找到类型或命名空间名称“ModelBuilder”(是否缺少 using 指令或程序集引用?) C:\Users\Administrator\Documents\Visual Studio 2010\Projects\MvcMovie\MvcApplication1\Models\Movie.cs 27 49 MvcMovie


C# code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;


namespace MvcApplication1.Models
{
    public class Movie
    {

            public int ID { get; set; }
            public string Title { get; set; }
            public DateTime ReleaseDate { get; set; }
            public string Genre { get; set; }
            public decimal Price { get; set; }
            public string Rating { get; set; }

    }

    public class MovieDBContext : DbContext
    {
        public DbSet<Movie> Movies { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Movie>().Property(p =>p.Price).HasPrecision(18, 2);
        }

    }

}


------解决方案--------------------
System.Data.Entity
要ef 5.0