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.(這個網站的例子,向我們展示了,怎樣使用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 candownload the completed application.
(這個示例程序是為Contoso University虛構的一個網站。網站的功能包含:招生模塊,課程的創建模塊,布置作業模塊,這個系列的課程將帶你創建這個網站,你可以通過這個鏈接下載完整的網站源代碼。)
3.課程中用到的軟件環境:
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.(你可以瀏覽,更新學生、課程信息,和老師信息,這里的一些頁面,將是你將來要創建的。)
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自己把界面美化一下。)
Open Visual Studio and create a new C# Web PRoject named "ContosoUniversity".(打開VS,創建一個新的web項目,取名為ContosoUniversity)
In theNew ASP.NET Projectdialog box select theMVCtemplate. (在新的ASP.NET項目中,選擇MVC模板)
If theHost in the cloudcheck box in theMicrosoft Azuresection is selected, clear it.(如果在云中托管被選中了,請取消勾選)
ClickChange Authentication.(點擊更改身份驗證)
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.(在更改身份驗證的對話框中,選擇無身份驗證,然后點擊確定。這個系列的課程,你不會被要求,需要讓用戶來登錄,或者限制用戶登錄)
Back in the New ASP.NET Project dialog box, clickOKto create the project. (返回到新建ASP.NET項目的界面,點擊確定,創建新項目)
A few simple changes will set up the site menu, layout, and home page.(我們會對菜單,樣式,和主頁做一些細微的改變)
OpenViews/Shared/_Layout.cshtml, and make the following changes:(打開Views/Shared/_Layout.cshtml文件,做如下改變)
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 @ScrInViews/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中,用下面的代碼,來代替它)
1 @{ 2 ViewBag.Title = "主頁"; 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 »</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 »</a></p>26 </div>27 </div>Press CTRL+F5 to run the site. You see the home page with the main menu.(按一下CTRL+F5,來運行項目,你可以看到:)
Install Entity Framework 6(安裝EF6)
From theToolsmenu clickNuGet Package Managerand then clickPackage Manager Console.(點擊工具-->NuGet程序包管理器--->程序包管理器控制臺)
In thePackage Manager Consolewindow enter the following command:(在程序包管理器控制臺窗口里,輸入下面的指令:)
Install-Package EntityFramework
The image shows 6.0.0 being installed, but NuGet will install the latest version of Enti
新聞熱點
疑難解答