MVC5 + EF6 简单示例

原文地址:http://www.cnblogs.com/panchunting/p/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application.html

MVC4+EF5+EasyUI+Unity3依赖注入(1)- 系统简要说明

http://www.cnblogs.com/hbsi/p/3632015.html

ASP.NET MVC5 网站开发实践

http://www.cnblogs.com/mzwhj/archive/2014/03/30/3634397.html

 EF5&MVC4 学习1、创建新的Contoso University Application,并创建Model Class 生成对应的database

http://www.cnblogs.com/siri/p/3628017.html

http://www.cnblogs.com/siri/category/558088.html

Creating an Entity Framework Data Model for an ASP.NET MVC Application (1 of 10)

http://www.asp.net/mvc/tutorials/getting-started-with-ef-5-using-mvc-4/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

最终效果如下图

 

模型类和数据上下文都是下拉菜单选择的。注意:在选择之前先编译一下你的代码,否则是找不到模型类和数据上下文类的

服务器资源管理器:

另外关于:

using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using EF6Demo.Models;

namespace EF6Demo.DAL
{
    public class CommunicationContext:DbContext
    {
        public CommunicationContext()
            : base("CommunicationContext")
        { 
            
        }
        public DbSet<EF6Demo.Models.Contact> Contacts { get; set; }
        public DbSet<EF6Demo.Models.Enrollment> Enrollments { get; set; }
        public DbSet<EF6Demo.Models.Group> Groups { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //base.OnModelCreating(modelBuilder);
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
    }
}

 

 modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();可以参考:

Entity Framework creates a plural table name, but the view expects a singular table name?

http://stackoverflow.com/questions/7924758/entity-framework-creates-a-plural-table-name-but-the-view-expects-a-singular-ta

MVC5 + EF6 简单示例(转载),古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。