国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

1.創(chuàng)建一個(gè)EF實(shí)體數(shù)據(jù)模型

2019-11-17 02:10:38
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

1.創(chuàng)建一個(gè)EF實(shí)體數(shù)據(jù)模型

1.The Contoso University sample web application demonstrates how to create 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, seeEntity Framework Development Workflows.(這個(gè)網(wǎng)站的例子,向我們展示了,怎樣使用EF6和VS2013來(lái)創(chuàng)建ASP.NET MVC5應(yīng)用程序。這個(gè)系列的課程使用了Code First工作流。要了解怎么在Code First,Database First 和Model First之間進(jìn)行選擇,請(qǐng)看鏈接這篇文章。)

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 candownload the completed application.

(這個(gè)示例程序是為Contoso University虛構(gòu)的一個(gè)網(wǎng)站。網(wǎng)站的功能包含:招生模塊,課程的創(chuàng)建模塊,布置作業(yè)模塊,這個(gè)系列的課程將帶你創(chuàng)建這個(gè)網(wǎng)站,你可以通過(guò)這個(gè)鏈接下載完整的網(wǎng)站源代碼。)

3.課程中用到的軟件環(huán)境:

  • 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.(在這個(gè)系列課程中,你將要?jiǎng)?chuàng)建的是一個(gè)大學(xué)的簡(jiǎn)單web網(wǎng)站)

Users can view and update student, course, and instructor information. Here are a few of the screens you'll create.(你可以瀏覽,更新學(xué)生、課程信息,和老師信息,這里的一些頁(yè)面,將是你將來(lái)要?jiǎng)?chuàng)建的。)

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.(這個(gè)網(wǎng)站的界面樣式,使用的是默認(rèn)提供的模板樣式,所以這個(gè)課程將會(huì)把主要的精力放在,怎樣去使用EF上面。PS:后面我會(huì)自己使用EasyUI和Bootstrap自己把界面美化一下。)

Create an MVC Web Application

Open Visual Studio and create a new C# Web PRoject named "ContosoUniversity".(打開(kāi)VS,創(chuàng)建一個(gè)新的web項(xiàng)目,取名為ContosoUniversity)

In theNew ASP.NET Projectdialog box select theMVCtemplate. (在新的ASP.NET項(xiàng)目中,選擇MVC模板)

If theHost in the cloudcheck box in theMicrosoft Azuresection is selected, clear it.(如果在云中托管被選中了,請(qǐng)取消勾選

ClickChange Authentication.(點(diǎn)擊更改身份驗(yàn)證)

In theChange Authenticationdialog box, selectNo Authentication, and then clickOK. For this tutorial you won't be requiring users to log on or restricting access based on who's logged on.(在更改身份驗(yàn)證的對(duì)話框中,選擇無(wú)身份驗(yàn)證,然后點(diǎn)擊確定。這個(gè)系列的課程,你不會(huì)被要求,需要讓用戶來(lái)登錄,或者限制用戶登錄)

Back in the New ASP.NET Project dialog box, clickOKto create the project. (返回到新建ASP.NET項(xiàng)目的界面,點(diǎn)擊確定,創(chuàng)建新項(xiàng)目)

Set Up the Site Style(設(shè)置站點(diǎn)的樣式)

A few simple changes will set up the site menu, layout, and home page.(我們會(huì)對(duì)菜單,樣式,和主頁(yè)做一些細(xì)微的改變)

OpenViews/Shared/_Layout.cshtml, and make the following changes:(打開(kāi)Views/Shared/_Layout.cshtml文件,做如下改變

  • Change each occurrence of "My ASP.NET Application" and "Application name" to "Contoso University".(把每個(gè)”My ASP.NET Application“和“Application name”改成“Contoso University”)PS:這里可以隨便改,你想取什么名字都行,我取武漢大學(xué)。
  • Add menu entries for Students, Courses, Instructors, and Departments, and delete the Contact entry.(為學(xué)生,課程,老師,部門添加菜單選項(xiàng)鏈接,并且刪除聯(lián)系方式鏈接)

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     @Scr

InViews/Home/Index.cshtml, replace the contents of the file with the following code to replace the text about ASP.NET and MVC with text about this application:(在Views/Home/Index.cshtml中,用下面的代碼,來(lái)代替它

 1 @{ 2     ViewBag.Title = "主頁(yè)"; 3 } 4  5 <div class="jumbotron"> 6     <h1>WuHan University</h1> 7 </div> 8 <div class="row"> 9     <div class="col-md-4">10         <h2>Welcome to WuHan University</h2>11         <p>12             WuHan University is a sample application that13             demonstrates how to use Entity Framework 6 in an14             ASP.NET MVC 5 web application.15         </p>16     </div>17     <div class="col-md-4">18         <h2>Build it from scratch</h2>19         <p>You can build the application by following the steps in the tutorial series on the ASP.NET site.</p>20         <p><a class="btn btn-default" >See the tutorial &raquo;</a></p>21     </div>22     <div class="col-md-4">23         <h2>Download it</h2>24         <p>You can download the completed project from the Microsoft Code Gallery.</p>25         <p><a class="btn btn-default" >Download &raquo;</a></p>26     </div>27 </div>

Press CTRL+F5 to run the site. You see the home page with the main menu.(按一下CTRL+F5,來(lái)運(yùn)行項(xiàng)目,你可以看到:)

Install Entity Framework 6(安裝EF6)

From theToolsmenu clickNuGet Package Managerand then clickPackage Manager Console.(點(diǎn)擊工具-->NuGet程序包管理器--->程序包管理器控制臺(tái))

In thePackage Manager Consolewindow enter the following command:(在程序包管理器控制臺(tái)窗口里,輸入下面的指令:)

Install-Package EntityFramework

The image shows 6.0.0 being installed, but NuGet will install the latest version of Enti

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 开远市| 晋中市| 樟树市| 龙里县| 广灵县| 会同县| 贵港市| 桐乡市| 新蔡县| 北碚区| 和顺县| 杭锦旗| 哈尔滨市| 黄大仙区| 勃利县| 宁津县| 绥化市| 新营市| 富宁县| 敦化市| 岳西县| 石楼县| 康定县| 曲周县| 马尔康县| 神农架林区| 东乌珠穆沁旗| 邵东县| 呈贡县| 弥勒县| 扎囊县| 泸西县| 柳州市| 新蔡县| 海城市| 苏尼特右旗| 东安县| 东乡族自治县| 安达市| 大田县| 治县。|