使用DBContext类生成.sdf文件?

时间:2011-08-13 20:40:21

标签: asp.net-mvc-2 entity-framework-4.1

我正在从

开始学习本教程

http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

我没有创建此代码:

using MvcApp2.Models;
using System.Data.Entity.Design.PluralizationServices;
using System.Data.Entity.ModelConfiguration.Conventions;


namespace MvcApp2.Models
{    
        public class StudentContext : DbContext
        {
            public DbSet<Student> Students { get; set; }
            public DbSet<Enrollment> Enrollments { get; set; }
            public DbSet<Course> Courses { get; set; }

            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            }
        }

}

在我的Web.config中我添加了这个连接字符串:

 <add name="StudentContext" connectionString="Data Source=|DataDirectory|Student.sdf" providerName="System.Data.SqlServerCe.4.0"/>

当我构建我的项目时,根据教程,我应该期待我的appcode被叫学生中的SDF文件

0 个答案:

没有答案