From 8573c18421cddf7d97d794c6b540293e6d96b3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=B6=9B?= Date: Tue, 16 Apr 2019 18:25:33 +0800 Subject: [PATCH] Update ASP.NET Core MVC Tutorial to solve issue #1010 --- docs/en/Tutorials/AspNetCore-Mvc/Part-I.md | 12 ++++++++++++ docs/zh-Hans/Tutorials/AspNetCore-Mvc/Part-I.md | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md b/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md index 337f021587..828608c2fd 100644 --- a/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md +++ b/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md @@ -89,6 +89,18 @@ EF Core requires you to relate entities with your DbContext. The easiest way to } ```` +#### Configure Your Book Entity + +Open BookStoreDbContextModelCreatingExtensions.cs file from the `Acme.BookStore.EntityFrameworkCore` project, add following code to the end of ConfigureBookStore method to configure Book entity: + +````C# + builder.Entity(b => + { + b.ToTable(BookStoreConsts.DbTablePrefix + "Books", BookStoreConsts.DbSchema); + b.ConfigureExtraProperties(); + }); +```` + #### Add New Migration & Update the Database The Startup template uses [EF Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/) to create and maintain the database schema. Open the **Package Manager Console (PMC)** (under the *Tools/Nuget Package Manager* menu), select the `Acme.BookStore.EntityFrameworkCore.DbMigrations` as the **default project** and execute the following command: diff --git a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/Part-I.md b/docs/zh-Hans/Tutorials/AspNetCore-Mvc/Part-I.md index fd29fdc7fe..f80570d8ce 100644 --- a/docs/zh-Hans/Tutorials/AspNetCore-Mvc/Part-I.md +++ b/docs/zh-Hans/Tutorials/AspNetCore-Mvc/Part-I.md @@ -89,6 +89,18 @@ public class BookStoreDbContext : AbpDbContext } ```` +#### 配置你的Book实体 + +从`Acme.BookStore.EntityFrameworkCore` 项目中打开 BookStoreDbContextModelCreatingExtensions.cs 文件, 在 ConfigureBookStore 方法最后添加如下代码来配置Book实体: + +````C# + builder.Entity(b => + { + b.ToTable(BookStoreConsts.DbTablePrefix + "Books", BookStoreConsts.DbSchema); + b.ConfigureExtraProperties(); + }); +```` + #### 添加新的Migration并更新数据库 这个启动模板使用了[EF Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/)来创建并维护数据库结构.打开 **程序包管理器控制台(Package Manager Console) (PMC)** (工具/Nuget包管理器菜单),选择 `Acme.BookStore.EntityFrameworkCore.DbMigrations`作为默认的项目然后执行下面的命令: