参考: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

Create The Contoso University Web Application

Contoso University sample web applicatioin 是一个使用MVC4 & EF5 & VS2012创建的Sample网站。网站功能包括:学生入学,课程选择,作业布置。这一系列的教程会教我们如何建立这个网站。

 

Code First

在Entiry Framework中,我们有三种处理数据的方法:Database First,Model First,and Code First.这个教程中,我们使用Code First。关于这三种之间的差别以及具体该选择哪种,可以参考Entity Framework Development Workflows

 

The Contoso University Web Application

功能:用户可以查看,更新学生、课程、教师信息。

这个Application的UI页面,是系统自动生成的Template。所以我们可以关注于怎么去用Entity Framework.之后我们再用Kendo UI去更新我们的UI。

 

准备(Prerequisits): Windows Azure SDK http://go.microsoft.com/fwlink/?LinkId=254364

 

一,创建一个MVC WEB Application

Create a new project named “ContosoUniversity”,Using .NET Framework 4.5

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

 

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

网站样式设置(Set Up The Site Style

我们会对网站的site menu,layout和home page做出一些更新

Views\Shared\_Layout.cshtml:更改母版页的标题,增加一些连接

<!DOCTYPE html>
<html lang="zh">
    <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - Contoso University</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("Contoso University", "Index", "Home")</p>
                </div>
                <div class="float-right">
                    <section id="login">
                        @Html.Partial("_LoginPartial")
                    </section>
                    <nav>
                        <ul id="menu">
                            <li>@Html.ActionLink("首頁", "Index", "Home")</li>
                            <li>@Html.ActionLink("關於", "About", "Home")</li>
                            <li>@Html.ActionLink("學生", "Student", "Home")</li>
                             <li>@Html.ActionLink("課程", "Course", "Home")</li>
                             <li>@Html.ActionLink("教師", "Instructors", "Home")</li>
                            <li>@Html.ActionLink("部門", "Departments", "Home")</li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>
            <div class="content-wrapper">
                <div class="float-left">
                    <p>&copy; @DateTime.Now.Year - Contoso University</p>
                </div>
            </div>
        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>
View Code

相关文章:

  • 2021-12-17
  • 2022-12-23
  • 2022-01-22
  • 2021-07-27
  • 2021-12-28
  • 2021-07-01
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2021-12-30
  • 2022-01-23
  • 2021-10-18
  • 2022-12-23
  • 2021-10-23
  • 2021-08-30
相关资源
相似解决方案