开发者

producing .sdf file using DBContext class?

I am follwoing this tutorial from

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

No I have created this code:

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>();
            }
        }

}

and in my Web.config I have added this Connection string:

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

When I build my project,according to the tutorial, I should be expecting an SDF file in my appcode callded s开发者_如何学Ctudents

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜