你的位置:首页 > 软件开发 > ASP.net > 1.创建一个EF实体数据模型

1.创建一个EF实体数据模型

发布时间:2015-06-24 00:00:15
1.The Contoso University sample web application demonstrates how to create ASP.NET MVC 5 applications using the Entity Framework 6 and Visua ...

1.The Contoso University sample web application demonstrates how to create get='_blank'>ASP.NET MVC 5 applications using the Entity Framework 6 and Visual Studio 2013. This tutorial uses the Code First workflow. For information about how to choose between Code First, Database First, and Model First, see Entity Framework Development Workflows.(这个网站的例子,向我们展示了,怎样使用EF6和VS2013来创建ASP.NET MVC5应用程序。这个系列的课程使用了Code First工作流。要了解怎么在Code First,Database First 和Model First之间进行选择,请看链接这篇文章。)

2.The sample application is a web site for a fictional Contoso University. It includes functionality such as student admission, course creation, and instructor assignments. This tutorial series explains how to build the Contoso University sample application. You can download the completed application.

(这个示例程序是为Contoso University虚构的一个网站。网站的功能包含:招生模块,课程的创建模块,布置作业模块,这个系列的课程将带你创建这个网站,你可以通过这个链接下载完整的网站源代码。)

3.课程中用到的软件环境:

  • Visual Studio 2013
  • .NET 4.5
  • Entity Framework 6 (EntityFramework 6.1.0 NuGet package)
  • Windows Azure SDK 2.2 (可选)

The Contoso University Web Application

The application you'll be building in these tutorials is a simple university web site.(在这个系列课程中,你将要创建的是一个大学的简单web网站)

Users can view and update student, course, and instructor information. Here are a few of the screens you'll create.(你可以浏览,更新学生、课程信息,和老师信息,这里的一些页面,将是你将来要创建的。)

1.创建一个EF实体数据模型

 

1.创建一个EF实体数据模型

The UI style of this site has been kept close to what's generated by the built-in templates, so that the tutorial can focus mainly on how to use the Entity Framework.(这个网站的界面样式,使用的是默认提供的模板样式,所以这个课程将会把主要的精力放在,怎样去使用EF上面。PS:后面我会自己使用EasyUI和Bootstrap自己把界面美化一下。)

Create an MVC Web Application

Open Visual Studio and create a new C# Web project named "ContosoUniversity".(打开VS,创建一个新的web项目,取名为ContosoUniversity)

1.创建一个EF实体数据模型

In the New ASP.NET Project dialog box select the MVC template. (在新的ASP.NET项目中,选择MVC模板)

If the Host in the cloud check box in the Microsoft Azure section is selected, clear it.(如果在云中托管被选中了,请取消勾选

Click Change Authentication.(点击更改身份验证)

1.创建一个EF实体数据模型

In the Change Authentication dialog box, select No Authentication, and then click OK. For this tutorial you won't be requiring users to log on or restricting access based on who's logged on.(在更改身份验证的对话框中,选择无身份验证,然后点击确定。这个系列的课程,你不会被要求,需要让用户来登录,或者限制用户登录)

1.创建一个EF实体数据模型

Back in the New ASP.NET Project dialog box, click OK to create the project. (返回到新建ASP.NET项目的界面,点击确定,创建新项目)

Set Up the Site Style(设置站点的样式)

A few simple changes will set up the site menu, layout, and home page.(我们会对菜单,样式,和主页做一些细微的改变)

Open Views\Shared\_Layout.cshtml, and make the following changes:(打开Views\Shared\_Layout.cshtml文件,做如下改变

  • Change each occurrence of "My ASP.NET Application" and "Application name" to "Contoso University".(把每个”My ASP.NET Application“和“Application name”改成“Contoso University”)PS:这里可以随便改,你想取什么名字都行,我取武汉大学。
  • Add menu entries for Students, Courses, Instructors, and Departments, and delete the Contact entry.(为学生,课程,老师,部门添加菜单选项链接,并且删除联系方式链接)

The changes are highlighted.(这些改变都做了高亮显示:)

 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 5   <meta charset="utf-8" /> 6   <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7   <title>@ViewBag.Title - WuHan University</title> 8   @Styles.Render("~/Content/css") 9   @Scripts.Render("~/bundles/modernizr")10 </head>11 <body>12   <div class="navbar navbar-inverse navbar-fixed-top">13     <div class="container">14       <div class="navbar-header">15         <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">16           <span class="icon-bar"></span>17           <span class="icon-bar"></span>18           <span class="icon-bar"></span>19         </button>20         @Html.ActionLink("Wuhan University", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })21       </div>22       <div class="navbar-collapse collapse">23         <ul class="nav navbar-nav">24           <li>@Html.ActionLink("主页", "Index", "Home")</li>25           <li>@Html.ActionLink("关于", "About", "Home")</li>26           <li>@Html.ActionLink("学生", "Index", "Student")</li>27           <li>@Html.ActionLink("课程", "Index", "Course")</li>28           <li>@Html.ActionLink("教师", "Index", "Instructor")</li>29           <li>@Html.ActionLink("部门", "Index", "Department")</li>30         </ul>31       </div>32     </div>33   </div>34   <div class="container body-content">35     @RenderBody()36     <hr />37     <footer>38       <p>&copy; @DateTime.Now.Year - Wuhan University</p>39     </footer>40   </div>41 42   @Scripts.Render("~/bundles/jquery")43   @Scripts.Render("~/bundles/bootstrap")44   @RenderSection("scripts", required: false)45 </body>46 </html>

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:1.创建一个EF实体数据模型

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录