ASP.NET MVC4 音乐商店,Entity Framework 5.0

在使用一下代码后

 

  public class MusicStoreEntities : DbContext
    {
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }

 

。。。。。}

出现问题:

 

The model backing the 'MusicStoreEntities' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

 

 

解决方案1:

 

在Global.asax.cs 中加入:

 

   public  class MvcApplication : System.Web.HttpApplication
    {
         protected  void Application_Start()
        {
            System.Data.Entity.Database.SetInitializer<Mvc4MusicStore.Models.MusicStoreEntities>( null );
     
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
    }

 

 

 

 

 

 

 

你可能感兴趣的:(framework)