Skip to content

Commit

Permalink
Merge pull request dotnet#2 from aspnet/master
Browse files Browse the repository at this point in the history
Refreshing my fork
  • Loading branch information
shadialnamrouti authored Jan 29, 2019
2 parents 5a1c284 + 396377b commit cd51bf1
Show file tree
Hide file tree
Showing 344 changed files with 2,271 additions and 2,745 deletions.
4 changes: 4 additions & 0 deletions .ghal.rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"labels": {
"product": {
"(?i).*": "Source - Docs.ms"
},
"contentsource": {
"(?i).*master\/aspnetcore\/signalr.*": "SignalR",
"(?i).*master\/aspnetcore\/tutorials\/signalr*.*": "SignalR"
}
}
}
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/doc-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ about: Create an issue to help us improve

# Before you open an issue

If the issue is with an ASP.NET Core document, open the issue with the **Content feedback** button at the bottom of that document page.

If the issue is:

- A simple typo or similar correction, you can submit a PR. See [the contributor guide](https://docs.microsoft.com/contribute/#quick-edits-to-existing-documents) for instructions.
Expand All @@ -15,7 +17,7 @@ If the issue is:

# Issue description

<include description here>
{ description here }

# Software versions

Expand Down
22 changes: 10 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,20 @@ DocFX requires:

### Mono instructions

* Install Mono via Homebrew: `brew install mono`.
* Download the [latest version of DocFX](https://github.com/dotnet/docfx/releases).
* Extract to `\bin\docfx`.
* Create an alias for **docfx**:
* Install Mono via Homebrew:

```
function docfx {
mono $HOME/bin/docfx/docfx.exe
}
function docfx-serve {
mono $HOME/bin/docfx/docfx.exe serve _site
}
brew install mono
```
* Download the [latest version of DocFX](https://github.com/dotnet/docfx/releases).
* Extract the archive to *$HOME/bin/docfx*.
* Create a pair of aliases for **docfx** in a bash shell. The first alias is used to build the documentation. The second alias is used to build and serve the documentation.

* Run `docfx` in the *Docs\aspnet* or *Docs\aspnetcore* directory to build the site. Run `docfx-serve` to view the site at `http://localhost:8080`.
```
alias docfx='mono $HOME/bin/docfx/docfx.exe'
alias docfx-serve='mono $HOME/bin/docfx/docfx.exe --serve'
```
* Execute `docfx` from the root of the repo to build the site. Execute `docfx-serve` to view the site at `http://localhost:8080`.

## Voice and tone

Expand Down
2 changes: 1 addition & 1 deletion aspnet/entity-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Use Entity Framework with ASP.NET

- [Web Forms Tutorials](web-forms/overview/older-versions-getting-started/getting-started-with-ef/the-entity-framework-and-aspnet-getting-started-part-1.md)
- [MVC Tutorials](mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application.md)
- [Sample Application](https://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8)
- [Sample Application](https://webpifeed.blob.core.windows.net/webpifeed/Partners/ASP.NET%20MVC%20Application%20Using%20Entity%20Framework%20Code%20First.zip)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

// For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
// string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
// var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
// await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

return RedirectToAction("Index", "Home");
}
AddErrors(result);
}

// If we got this far, something failed, redisplay form
return View(model);
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
---
uid: mvc/overview/getting-started/database-first-development/creating-the-web-application
title: "EF Database First with ASP.NET MVC: Creating the Web Application and Data Models | Microsoft Docs"
title: "Tutorial: Create the the Web Application and Data Models for EF Database First with ASP.NET MVC"
description: "This tutorial focuses on creating the web application, and generating the data models based on your database tables."
author: Rick-Anderson
description: "Using MVC, Entity Framework, and ASP.NET Scaffolding, you can create a web application that provides an interface to an existing database. This tutorial seri..."
ms.author: riande
ms.date: 10/01/2014
ms.date: 01/28/2019
ms.topic: tutorial
ms.assetid: bc8f2bd5-ff57-4dcd-8418-a5bd517d8953
msc.legacyurl: /mvc/overview/getting-started/database-first-development/creating-the-web-application
msc.type: authoredcontent
---
EF Database First with ASP.NET MVC: Creating the Web Application and Data Models
====================
by [Tom FitzMacken](https://github.com/tfitzmac)

> Using MVC, Entity Framework, and ASP.NET Scaffolding, you can create a web application that provides an interface to an existing database. This tutorial series shows you how to automatically generate code that enables users to display, edit, create, and delete data that resides in a database table. The generated code corresponds to the columns in the database table.
>
> This part of the series focuses on creating the web application, and generating the data models based on your database tables.
# Tutorial: Create the the Web Application and Data Models for EF Database First with ASP.NET MVC

Using MVC, Entity Framework, and ASP.NET Scaffolding, you can create a web application that provides an interface to an existing database. This tutorial series shows you how to automatically generate code that enables users to display, edit, create, and delete data that resides in a database table. The generated code corresponds to the columns in the database table.

## Create a new ASP.NET Web Application
This tutorial focuses on creating the web application, and generating the data models based on your database tables.

In this tutorial, you:

> [!div class="checklist"]
> * Create an ASP.NET web app
> * Generate the models
## Prerequisites

* [Getting started with Entity Framework 6 Database First using MVC 5](setting-up-database.md)

## Create an ASP.NET web app

In either a new solution or the same solution as the database project, create a new project in Visual Studio and select the **ASP.NET Web Application** template. Name the project **ContosoSite**.

Expand All @@ -28,8 +37,6 @@ Click **OK**.

In the New ASP.NET Project window, select the **MVC** template. You can clear the **Host in the cloud** option for now because you will deploy the application to the cloud later. Click **OK** to create the application.

![select mvc template](creating-the-web-application/_static/image2.png)

The project is created with the default files and folders.

In this tutorial, you will use Entity Framework 6. You can double-check the version of Entity Framework in your project through the Manage NuGet Packages window. If necessary, update your version of Entity Framework.
Expand All @@ -42,40 +49,32 @@ You will now create Entity Framework models from the database tables. These mode

Right-click the **Models** folder, and select **Add** and **New Item**.

![add new item](creating-the-web-application/_static/image4.png)

In the Add New Item window, select **Data** in the left pane and **ADO.NET Entity Data Model** from the options in the center pane. Name the new model file **ContosoModel**.

![create model](creating-the-web-application/_static/image5.png)

Click **Add**.

In the Entity Data Model Wizard, select **EF Designer from database**.

![generate from database](creating-the-web-application/_static/image6.png)

Click **Next**.

If you have database connections defined within your development environment, you may see one of these connections pre-selected. However, you want to create a new connection to the database you created in the first part of this tutorial. Click the **New Connection** button.

![connect to database](creating-the-web-application/_static/image7.png)

In the Connection Properties window, provide the name of the local server where your database was created (in this case **(localdb)\ProjectsV12**). After providing the server name, select the ContosoUniversityData from the available databases.
In the Connection Properties window, provide the name of the local server where your database was created (in this case **(localdb)\Projects13**). After providing the server name, select the ContosoUniversityData from the available databases.

![set connection properties](creating-the-web-application/_static/image8.png)

Click **OK**.

The correct connection properties are now displayed. You can use the default name for connection in the Web.Config file
The correct connection properties are now displayed. You can use the default name for connection in the Web.Config file.

Click **Next**.

![connection settings](creating-the-web-application/_static/image9.png)
Select the latest version of Entity Framework.

Click **Next**.

Select **Tables** to generate models for all three tables.

![select tables](creating-the-web-application/_static/image10.png)

Click **Finish**.

If you receive a security warning, select **OK** to continue running the template.
Expand All @@ -86,12 +85,18 @@ The models are generated from the database tables, and a diagram is displayed th

The Models folder now includes many new files related to the models that were generated from the database.

![show new model files](creating-the-web-application/_static/image12.png)

The **ContosoModel.Context.cs** file contains a class that derives from the **DbContext** class, and provides a property for each model class that corresponds to a database table. The **Course.cs**, **Enrollment.cs**, and **Student.cs** files contain the model classes that represent the databases tables. You will use both the context class and the model classes when working with scaffolding.

Before proceeding with this tutorial, build the project. In the next section, you will generate code based on the data models, but that section will not work if the project has not been built.

> [!div class="step-by-step"]
> [Previous](setting-up-database.md)
> [Next](generating-views.md)
## Next steps

In this tutorial, you:

> [!div class="checklist"]
> * Created an ASP.NET web app
> * Generated the models
Advance to the next tutorial to learn how to create generate code based on the data models.
> [!div class="nextstepaction"]
> [Generating views](generating-views.md)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
---
uid: mvc/overview/getting-started/database-first-development/customizing-a-view
title: "EF Database First with ASP.NET MVC: Customizing a View | Microsoft Docs"
title: "Tutorial: Customize view for EF Database First with ASP.NET MVC app"
description: "This tutorial focuses on changing the automatically-generated views to enhance the presentation."
author: Rick-Anderson
description: "Using MVC, Entity Framework, and ASP.NET Scaffolding, you can create a web application that provides an interface to an existing database. This tutorial seri..."
ms.author: riande
ms.date: 10/01/2014
ms.date: 01/24/2019
ms.topic: tutorial
ms.assetid: 269380ff-d7e1-4035-8ad1-fe1316a25f76
msc.legacyurl: /mvc/overview/getting-started/database-first-development/customizing-a-view
msc.type: authoredcontent
---
EF Database First with ASP.NET MVC: Customizing a View
====================
by [Tom FitzMacken](https://github.com/tfitzmac)

> Using MVC, Entity Framework, and ASP.NET Scaffolding, you can create a web application that provides an interface to an existing database. This tutorial series shows you how to automatically generate code that enables users to display, edit, create, and delete data that resides in a database table. The generated code corresponds to the columns in the database table.
>
> This part of the series focuses on changing the automatically-generated views to enhance the presentation.
# Tutorial: Customize view for EF Database First with ASP.NET MVC app

Using MVC, Entity Framework, and ASP.NET Scaffolding, you can create a web application that provides an interface to an existing database. This tutorial series shows you how to automatically generate code that enables users to display, edit, create, and delete data that resides in a database table. The generated code corresponds to the columns in the database table.

## Add enrolled courses to student details
This tutorial focuses on changing the automatically-generated views to enhance the presentation.

In this tutorial, you:

> [!div class="checklist"]
> * Add courses to the student detail page
> * Confirm that the courses are added to the page
## Prerequisites

* [Change the database](changing-the-database.md)

## Add courses to student detail

The generated code provides a good starting point for your application but it does not necessarily provide all of the functionality that you need in your application. You can customize the code to meet the particular requirements of your application. Currently, your application does not display the enrolled courses for the selected student. In this section, you will add the enrolled courses for each student to the **Details** view for the student.

Open **Students/Details.cshtml**, and below the last &lt;/dl&gt; tab, but before the closing &lt;/div&gt; tag, add the following code.
Open **Views** > **Students** > *Details.cshtml*. Below the last &lt;/dl&gt; tag, but before the closing &lt;/div&gt; tag, add the following code.

[!code-cshtml[Main](customizing-a-view/samples/sample1.cshtml)]

This code creates a table that displays a row for each record in the Enrollment table for the selected student. The **Display** method renders HTML for the object (modelItem) that represents the expression. You use the Display method (rather than simply embedding the property value in the code) to make sure the value is formatted correctly based on its type and the template for that type. In this example, each expression returns a single property from the current record in the loop, and the values are primitive types which are rendered as text.

Browse to the Students/Index view again and select **Details** for one of the students. You will see the enrolled courses have been included in the view.
## Confirm courses are added

Run the solution. Click **List of students** and select **Details** for one of the students. You will see the enrolled courses have been included in the view.

![student with enrollment](customizing-a-view/_static/image1.png)

> [!div class="step-by-step"]
> [Previous](changing-the-database.md)
> [Next](enhancing-data-validation.md)
## Next steps
In this tutorial, you:

> [!div class="checklist"]
> * Added courses to the student detail page
> * Confirmed that the courses are added to the page
Advance to the next tutorial to learn how to add data annotations to specify validation requirements and display formatting.
> [!div class="nextstepaction"]
> [Enhance data validation](enhancing-data-validation.md)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cd51bf1

Please sign in to comment.