Browse Source

Merge pull request #9128 from abpframework/auto-merge/rel-4-3/408

Merge branch dev with rel-4.3
pull/9131/head
maliming 5 years ago
committed by GitHub
parent
commit
9892ff29e9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      docs/en/Modules/Cms-Kit/Blogging.md
  2. 73
      docs/en/Modules/Cms-Kit/Comments.md
  3. 94
      docs/en/Modules/Cms-Kit/Index.md
  4. 27
      docs/en/Modules/Cms-Kit/Pages.md
  5. 50
      docs/en/Modules/Cms-Kit/Ratings.md
  6. 56
      docs/en/Modules/Cms-Kit/Reactions.md
  7. 88
      docs/en/Modules/Cms-Kit/Tags.md
  8. 18
      docs/en/Tutorials/Part-1.md
  9. 10
      docs/en/Tutorials/Part-10.md
  10. 18
      docs/en/Tutorials/Part-7.md
  11. BIN
      docs/en/Tutorials/images/bookstore-efcore-migration-authors.png
  12. BIN
      docs/en/Tutorials/images/bookstore-efcore-migration.png
  13. 16
      docs/zh-Hans/Tutorials/Part-1.md
  14. BIN
      docs/zh-Hans/Tutorials/images/bookstore-efcore-migration.png

48
docs/en/Modules/Cms-Kit/Blogging.md

@ -2,15 +2,51 @@
The blogging feature provides the necessary UI to manage and render blogs and blog posts.
## Internals
## User Interface
Menu Items
### Menu Items
The following menu items are added by the blogging feature to the admin application:
* **Blogs**: Blog management page.
* **Blog Posts**: Blog post management page.
## Pages
### Blogs
Blogs page is used to create and manage blogs in your system.
![blogs-page](../../images/cmskit-module-blogs-page.png)
A screenshot from the new blog creation modal:
![blogs-edit](../../images/cmskit-module-blogs-edit.png)
**Slug** is the URL part of the blog. For this example, the root URL of the blog becomes *https://your-domain.com/blogs/technical-blog/*.
#### Blog Features
Blog feature uses some of the other CMS Kit features. You can enable or disable the features by clicking the features action for a blog.
![blogs-feature-action](../../images/cmskit-module-blogs-feature-action.png)
You can select/deselect the desired features for blog posts.
![features-dialog](../../images/cmskit-module-features-dialog.png)
### Blog Post Management
When you create blogs, you can manage blog posts on this page.
![blog-posts-page](../../images/cmskit-module-blog-posts-page.png)
You can create and edit an existing blog post on this page. If you enable specific features such as tags, you can set tags for the blog post on this page.
![blog-post-edit](../../images/cmskit-module-blog-post-edit.png)
## Internals
### Domain Layer
#### Aggregates
@ -33,9 +69,9 @@ This module follows the [Repository Best Practices & Conventions](https://docs.a
This module follows the [Domain Services Best Practices & Conventions](https://docs.abp.io/en/abp/latest/Best-Practices/Domain-Services) guide.
- `BlogManager`: Includes some operations for `Blog` aggregate root to keep data consistency.
- `BlogPostManager`: Includes some operations for `BlogPost` aggregate root such as creating & updating.
- `BlogFeatureManager`: Includes some operations for managing blog features.
- `BlogManager`
- `BlogPostManager`
- `BlogFeatureManager`
### Application layer
@ -43,7 +79,7 @@ This module follows the [Domain Services Best Practices & Conventions](https://d
##### Common
- `BlogFeatureAppService` _(implements I`BlogFeatureAppService`)_
- `BlogFeatureAppService` _(implements `IBlogFeatureAppService`)_
##### Admin

73
docs/en/Modules/Cms-Kit/Comments.md

@ -1,23 +1,10 @@
# Comment System
# CMS Kit: Comments
CMS kit provides a **comment** system to add comments feature to any kind of resource, like blog posts, products, etc. This section describes the details of the comments system.
CMS kit provides a **comment** system to add comments feature to any kind of resource, like blog posts, products, etc.
## Feature
## Options
CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with public website option. If you're installing the CMS kit manually or want to enable the comment feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method.
```csharp
GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit =>
{
cmsKit.Comments.Enable();
});
```
# Options
## CmsKitCommentOptions
You can use the comment system to add comments to any kind of resources, like blog posts, products etc. Comment system provides a mechanism to group comment definitions by entity types. For example, if you want to use comment system for blog posts and products, you need to define two entity types named `BlogPosts` and `Product`, and add comments under these entity types.
The comment system provides a mechanism to group comment definitions by entity types. For example, if you want to use comment system for blog posts and products, you need to define two entity types named `BlogPosts` and `Product`, and add comments under these entity types.
`CmsKitCommentOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example:
@ -38,9 +25,43 @@ Configure<CmsKitCommentOptions>(options =>
- `EntityType`: Name of the entity type.
# Internals
## The Comments Widget
The comment system provides a commenting [widget](../../UI/AspNetCore/Widgets.md) to allow users to send comments to resources on public websites. You can simply place the widget on a page like below.
```csharp
@await Component.InvokeAsync(typeof(CommentingViewComponent), new
{
entityType = "Product",
entityId = "..."
})
```
`entityType` was explained in the previous section. `entityId` should be the unique id of the product, in this example. If you have a Product entity, you can use its Id here.
## User Interface
### Menu Items
## Domain Layer
The following menu items are added by the commenting feature to the admin application:
* **Comments**: Opens the comment management page.
### Pages
#### Comment Management
You can view and manage comments on this page.
![comment-page](../../images/cmskit-module-comment-page.png)
You can also view and manage replies on this page.
![comments-detail](../../images/cmskit-module-comments-detail.png)
## Internals
### Domain Layer
#### Aggregates
@ -101,17 +122,3 @@ See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-String
- **CmsComments**
### MVC UI
The comment system provides a commenting widget to allow users to send comments to resources on public websites. You can simply place the widget on a page like below.
```csharp
@await Component.InvokeAsync(typeof(CommentingViewComponent), new
{
entityType = "entityType",
entityId = "entityId"
})
```
You need to specify entity type and entity ID parameters. Entity type represents the group name you specified while defining the comments in the domain module. Entity ID represents the unique identifier for the resource that users send comments to, such as blog post ID or product ID.
For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation.

94
docs/en/Modules/Cms-Kit/Index.md

@ -2,7 +2,7 @@
This module provides CMS (Content Management System) capabilities for your application. It provides **core building blocks** and fully working **sub-systems** to create your own website with CMS features enabled, or use the building blocks in your web sites with any purpose.
> **This module currently available only for the MVC UI**. While there is no official Blazor package, it can also work in a Blazor Server UI since a Blazor Server UI application is actually a hybrid application that runs within the MVC UI.
> **This module currently available only for the MVC / Razor Pages UI**. While there is no official Blazor package, it can also work in a Blazor Server UI since a Blazor Server UI is actually a hybrid application that runs in an ASP.NET Core MVC / Razor Pages application.
The following features are currently available:
@ -55,98 +55,6 @@ CMS kit packages are designed for various usage scenarios. If you check the [CMS
- `Volo.CmsKit.Public.*` packages contain the functionalities used in public websites where users read blog posts or leave comments.
- `Volo.CmsKit.*` (without Admin/Public suffix) packages are called as unified packages. Unified packages are shortcuts for adding Admin & Public packages (of the related layer) separately. If you have a single application for administration and public web site, you can use these packages.
## The User Interface
### Menu items
CMS Kit module admin side adds the following items to the main menu, under the *CMS* menu item:
* **Pages**: Page management page.
* **Tags**: Tag management page.
* **Comments**: Comment management page.
`CmsKitAdminMenus` class has the constants for the menu item names.
### Pages
### Page Management
Pages page is used to manage dynamic pages in the system.
![pages-page](../../images/cmskit-module-pages-page.png)
You can create or edit an existing page on this page.
![pages-edit](../../images/cmskit-module-pages-edit.png)
* When you create a page, you can access the created page via `pages/{slug}` URL.
### Blog Management
Blogs page is used to create and manage blogs in your system.
![blogs-page](../../images/cmskit-module-blogs-page.png)
A screenshot from the new blog creation modal:
![blogs-edit](../../images/cmskit-module-blogs-edit.png)
#### Blog Features
You can enable or disable a specific feature for blogs by clicking the features action.
![blogs-feature-action](../../images/cmskit-module-blogs-feature-action.png)
You can select/deselect the desired features for blog posts.
![features-dialog](../../images/cmskit-module-features-dialog.png)
### Blog Post Management
When you create blogs, you can manage blog posts on this page.
![blog-posts-page](../../images/cmskit-module-blog-posts-page.png)
You can create and edit an existing blog post on this page. If you enable specific features such as tags, you can set tags for the blog post on this page.
![blog-post-edit](../../images/cmskit-module-blog-post-edit.png)
### Tag Management
CMS Kit provides an extensible tagging mechanism to add tagging capabilities to various places.
![tags-page](../../images/cmskit-module-tags-page.png)
You can create or edit an existing tag on this page.
![tag-edit](../../images/cmskit-module-tag-edit.png)
### Comment Management
CMS Kit provides an extensible commenting mechanism to add comments to various places. You can add comment control to anywhere you want and manage the comments.
You can view and manage comments on this page.
![comment-page](../../images/cmskit-module-comment-page.png)
You can manage and view replies on this page.
![comments-detail](../../images/cmskit-module-comments-detail.png)
### Reactions
CMS Kit provides an extensible reaction component system to allow users to send reactions to your content. Here how the reactions component looks on a sample page.
![reactions](../../images/cmskit-module-reactions.png)
You can also customize the reaction icons shown in the reaction component.
### Ratings
You can use the rating component to add rating a mechanism to your content. Here how the rating component looks on a sample page.
![ratings](../../images/cmskit-module-ratings.png)
## Internals
### Table / collection prefix & schema

27
docs/en/Modules/Cms-Kit/Pages.md

@ -1,3 +1,28 @@
# CMS Kit: Pages
This document is in progress...
CMS Kit Page system allows you to create dynamic pages by specifying URLs, which is the fundamental feature of a CMS.
## The User Interface
### Menu items
CMS Kit module admin side adds the following items to the main menu, under the *CMS* menu item:
* **Pages**: Page management page.
`CmsKitAdminMenus` class has the constants for the menu item names.
### Pages
#### Page Management
Pages page is used to manage dynamic pages in the system.
![pages-page](../../images/cmskit-module-pages-page.png)
You can create or edit an existing page on this page.
![pages-edit](../../images/cmskit-module-pages-edit.png)
When you create a page, you can access the created page via `/pages/{slug}` URL.

50
docs/en/Modules/Cms-Kit/Ratings.md

@ -1,23 +1,12 @@
# Rating System
CMS kit provides a **rating** system to to add ratings feature to any kind of resource like blog posts, comments, etc. This section describes the details of the rating system.
CMS kit provides a **rating** system to to add ratings feature to any kind of resource like blog posts, comments, etc. Here how the rating component looks like on a sample page:
## Feature
![ratings](../../images/cmskit-module-ratings.png)
CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with the public website option. If you're installing the CMS kit manually or want to enable the rating feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method.
## Options
```csharp
GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit =>
{
cmsKit.Ratings.Enable();
});
```
# Options
## CmsKitRatingOptions
You can use the rating system to to add ratings to any kind of resource, like blog posts, comments, etc. The rating system provides a mechanism to group ratings by entity types. For example, if you want to use the rating system for products, you need to define an entity type named `Product` and then add ratings under the defined entity type.
The rating system provides a mechanism to group ratings by entity types. For example, if you want to use the rating system for products, you need to define an entity type named `Product` and then add ratings under the defined entity type.
`CmsKitRatingOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example:
@ -38,6 +27,20 @@ Configure<CmsKitRatingOptions>(options =>
- `EntityType`: Name of the entity type.
## The Rating Widget
The ratings system provides a rating widget to allow users send ratings to resources in public websites. You can simply place the widget on a page like below.
```csharp
@await Component.InvokeAsync(typeof(RatingViewComponent), new
{
entityType = "Product",
entityId = "entityId"
})
```
`entityType` was explained in the previous section. `entityId` should be the unique id of the product, in this example. If you have a Product entity, you can use its Id here.
# Internals
## Domain Layer
@ -98,19 +101,4 @@ See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-String
##### Collections
- **CmsRatings**
### MVC UI
The ratings system provides a rating widget to allow users send ratings to resources in public websites. You can simply place the widget on a page like below.
```csharp
@await Component.InvokeAsync(typeof(RatingViewComponent), new
{
entityType = "entityType",
entityId = "entityId"
})
```
You need to specify entity type and entity ID parameters. Entity type represents the group name you specified while defining the reactions in the domain module. Entity ID represents the unique identifier for the resource that users give ratings to, such as blog post ID or product ID.
For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation.
- **CmsRatings**

56
docs/en/Modules/Cms-Kit/Reactions.md

@ -1,23 +1,16 @@
# Reaction System
CMS kit provides a **reaction** system to add reactions feature to any kind of resource, like blog posts or comments. This section describes the details of the reaction system.
CMS kit provides a **reaction** system to add reactions feature to any kind of resource, like blog posts or comments.
## Feature
Reaction component allows users to react to your content via pre-defined icons/emojis. Here how the reactions component may looks like:
CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with the public website option. If you're installing the CMS kit manually or want to enable reaction feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method.
![reactions](../../images/cmskit-module-reactions.png)
```csharp
GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit =>
{
cmsKit.Reactions.Enable();
});
```
# Options
You can also customize the reaction icons shown in the reaction component.
## CmsKitReactionOptions
## Options
You can use the reaction system to to add reactions feature to any kind of resource, like blog posts or comments, etc. The reaction system provides a mechanism to group reactions by entity types. For example, if you want to use the reaction system for products, you need to define an entity type named `Product`, and then add reactions under the defined entity type.
Reaction system provides a mechanism to group reactions by entity types. For example, if you want to use the reaction system for products, you need to define an entity type named `Product`, and then add reactions under the defined entity type.
`CmsKitReactionOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example:
@ -39,16 +32,30 @@ Configure<CmsKitReactionOptions>(options =>
});
```
> If you're using the comment or blog features, the ABP framework defines predefined reactions for these features automatically. You can easily override or remove the predefined reactions in `Configure` method like shown above.
> If you're using the comment or blog features, the ABP framework defines predefined reactions for these features automatically.
`CmsKitReactionOptions` properties:
- `EntityTypes`: List of defined entity types(`CmsKitReactionOptions`) in the reaction system.
- `EntityTypes`: List of defined entity types (`CmsKitReactionOptions`) in the reaction system.
`ReactionEntityTypeDefinition` properties:asdas
`ReactionEntityTypeDefinition` properties:
- `EntityType`: Name of the entity type.
- `Reactions`: List of defined reactions(`ReactionDefinition`) in the entity type.
- `Reactions`: List of defined reactions (`ReactionDefinition`) in the entity type.
## The Reactions Widget
The reaction system provides a reaction widget to allow users to send reactions to resources. You can place the widget on a page like below:
```csharp
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new
{
entityType = "Product",
entityId = "..."
})
```
`entityType` was explained in the previous section. `entityId` should be the unique id of the product, in this example. If you have a Product entity, you can use its Id here.
# Internals
@ -111,18 +118,3 @@ See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-String
##### Collections
- **CmsUserReactions**
### MVC UI
The reaction system provides a reaction widget to allow users to send reactions to resources on public websites. You can place the widget on a page like below.
```csharp
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new
{
entityType = "entityType",
entityId = "entityId"
})
```
You need to specify entity type and entity ID parameters. Entity type represents the group name you specified while defining the reactions in the domain module. Entity ID represents the unique identifier for the resource that users give reactions to, such as blog post ID or product ID.
For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation.

88
docs/en/Modules/Cms-Kit/Tags.md

@ -1,25 +1,14 @@
# Tag Management
CMS kit provides a **tag** system to tag any kind of resources, like blog posts. This section describes the details of the tag system.
CMS kit provides a **tag** system to tag any kind of resources, like a blog post.
## Feature
## Options
CMS kit uses the [global feature](https://docs.abp.io/en/abp/latest/Global-Features) system for all implemented features. Commercial startup templates come with all the CMS kit related features are enabled by default, if you create the solution with public website option. If you're installing the CMS kit manually or want to enable the tag management feature individually, open the `GlobalFeatureConfigurator` class in the `Domain.Shared` project and place the following code to the `Configure ` method.
The tag system provides a mechanism to group tags by entity types. For example, if you want to use the tag system for blog posts and products, you need to define two entity types named `BlogPosts` and `Product` and add tags under these entity types.
```csharp
GlobalFeatureManager.Instance.Modules.CmsKit(cmsKit =>
{
cmsKit.Tags.Enable();
});
```
# Options
`CmsKitTagOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics) class.
## CmsKitTagOptions
You can use the tag system to tag any kind of resources, like blog posts, products, etc. The tag system provides a mechanism to group tags by entity types. For example, if you want to use the tag system for blog posts and products, you need to define two entity types named `BlogPosts` and `Product` and add tags under these entity types.
`CmsKitTagOptions` can be configured in the domain layer, in the `ConfigureServices` method of your [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics). Example:
**Example: Adding tagging support for products**
```csharp
Configure<CmsKitTagOptions>(options =>
@ -28,7 +17,7 @@ Configure<CmsKitTagOptions>(options =>
});
```
> If you're using the blog feature, the ABP framework defines an entity type for the blog feature automatically. You can easily override or remove the predefined entity types in `Configure` method like shown above.
> If you're using the blog feature, the ABP framework defines an entity type for the blog feature automatically.
`CmsKitTagOptions` properties:
@ -38,13 +27,47 @@ Configure<CmsKitTagOptions>(options =>
- `EntityType`: Name of the entity type.
- `DisplayName`: Display name of the entity type. You can use a user friendly display name to show entity type definition on the admin website.
- `CreatePolicies`: List of policy names allowing users to create tags under the entity type.
- `UpdatePolicies`: List of policy names allowing users to update tags under the entity type.
- `DeletePolicies`: List of policy names allowing users to delete tags under the entity type.
- `CreatePolicies`: List of policy/permission names allowing users to create tags under the entity type.
- `UpdatePolicies`: List of policy/permission names allowing users to update tags under the entity type.
- `DeletePolicies`: List of policy/permission names allowing users to delete tags under the entity type.
## The Tag Widget
The tag system provides a tag [widget](../../UI/AspNetCore/Widgets.md) to display associated tags of a resource that was configured for tagging. You can simply place the widget on a page like below:
```csharp
@await Component.InvokeAsync(typeof(TagViewComponent), new
{
entityType = "Product",
entityId = "..."
})
```
`entityType` was explained in the previous section. `entityId` should be the unique id of the product, in this example. If you have a Product entity, you can use its Id here.
## User Interface
### Menu Items
# Internals
The following menu items are added by the tagging feature to the admin application:
## Domain Layer
* **Tags**: Opens the tag management page.
### Pages
#### Tag Management
This page can be used to create, edit and delete tags for the entity types.
![tags-page](../../images/cmskit-module-tags-page.png)
You can create or edit an existing tag on this page.
![tag-edit](../../images/cmskit-module-tag-edit.png)
## Internals
### Domain Layer
#### Aggregates
@ -87,9 +110,9 @@ This module follows the [Domain Services Best Practices & Conventions](https://d
#### Application services
- `TagAdminAppService` (implements `ITagAdminAppService`): Implements the use cases of tag management.
- `EntityTagAdminAppService` (implements `IEntityTagAdminAppService`): Implements the use cases of entity tag relationship.
- `TagAppService` (implements `ITagAppService`): Implements the use cases of entity tag relationship for public websites.
- `TagAdminAppService` (implements `ITagAdminAppService`).
- `EntityTagAdminAppService` (implements `IEntityTagAdminAppService`).
- `TagAppService` (implements `ITagAppService`).
### Database providers
@ -111,7 +134,6 @@ See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-String
- CmsTags
- CmsEntityTags
- CmsTags
#### MongoDB
@ -119,17 +141,3 @@ See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-String
- **CmsTags**
- **CmsEntityTags**
### MVC UI
The tag system provides a tag widget to display associated tags of the resource on public websites. You can simply place the widget on a page like below.
```csharp
@await Component.InvokeAsync(typeof(TagViewComponent), new
{
entityType = "entityType",
entityId = "entityId"
})
```
For more information about widgets see [widgets](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Widgets) documentation.

18
docs/en/Tutorials/Part-1.md

@ -177,25 +177,19 @@ namespace Acme.BookStore.EntityFrameworkCore
### Add Database Migration
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 menu *Tools > NuGet Package Manager*.
The startup solution is configured to use [Entity Framework Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). Since we've changed the database mapping configuration, we should create a new migration and apply changes to the database.
![Open Package Manager Console](images/bookstore-open-package-manager-console.png)
Select the `Acme.BookStore.EntityFrameworkCore.DbMigrations` as the **default project** and execute the following command:
Open a command-line terminal in the directory of the `Acme.BookStore.EntityFrameworkCore.DbMigrations` project and type the following command:
```bash
Add-Migration "Created_Book_Entity"
dotnet ef migrations add Created_Book_Entity
```
![bookstore-pmc-add-book-migration](./images/bookstore-pmc-add-book-migration-v2.png)
> If you get an error like "*Your startup project ... doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work*", right click to the `Acme.BookStore.EntityFrameworkCore.DbMigrations` project and **Set as the Startup Project** and try again.
This will create a new migration class inside the `Migrations` folder of the `Acme.BookStore.EntityFrameworkCore.DbMigrations` project.
This will add a new migration class to the project:
Before updating the database, read the section below to learn how to seed some initial data to the database.
![bookstore-efcore-migration](./images/bookstore-efcore-migration.png)
> If you are using another IDE than the Visual Studio, you can use `dotnet-ef` tool as [documented here](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-a-migration).
> If you are using Visual Studio, you may want to use `Add-Migration Created_Book_Entity -c BookStoreMigrationsDbContext` and `Update-Database -c BookStoreMigrationsDbContext` commands in the *Package Manager Console (PMC)*. In this case, ensure that {{if UI=="MVC"}}`Acme.BookStore.Web`{{else if UI=="BlazorServer"}}`Acme.BookStore.Blazor`{{else if UI=="Blazor" || UI=="NG"}}`Acme.BookStore.HttpApi.Host`{{end}} is the startup project and `Acme.BookStore.EntityFrameworkCore.DbMigrations` is the *Default Project* in PMC.
{{end}}

10
docs/en/Tutorials/Part-10.md

@ -86,14 +86,14 @@ builder.Entity<Book>(b =>
### Add New EF Core Migration
Run the following command in the Package Manager Console (of the Visual Studio) to add a new database migration:
The startup solution is configured to use [Entity Framework Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). Since we've changed the database mapping configuration, we should create a new migration and apply changes to the database.
Open a command-line terminal in the directory of the `Acme.BookStore.EntityFrameworkCore.DbMigrations` project and type the following command:
````bash
Add-Migration "Added_AuthorId_To_Book"
dotnet ef migrations add Added_AuthorId_To_Book
````
> Ensure that the `Acme.BookStore.EntityFrameworkCore.DbMigrations` is the Default project and the `Acme.BookStore.DbMigrator` is the startup project, as always.
This should create a new migration class with the following code in its `Up` method:
````csharp
@ -121,6 +121,8 @@ migrationBuilder.AddForeignKey(
* Creates an index on the `AuthorId` field.
* Declares the foreign key to the `AppAuthors` table.
> If you are using Visual Studio, you may want to use `Add-Migration Added_AuthorId_To_Book -c BookStoreMigrationsDbContext` and `Update-Database -c BookStoreMigrationsDbContext` commands in the *Package Manager Console (PMC)*. In this case, ensure that {{if UI=="MVC"}}`Acme.BookStore.Web`{{else if UI=="BlazorServer"}}`Acme.BookStore.Blazor`{{else if UI=="Blazor" || UI=="NG"}}`Acme.BookStore.HttpApi.Host`{{end}} is the startup project and `Acme.BookStore.EntityFrameworkCore.DbMigrations` is the *Default Project* in PMC.
{{end}}
## Change the Data Seeder

18
docs/en/Tutorials/Part-7.md

@ -70,19 +70,25 @@ This is just like done for the `Book` entity before, so no need to explain again
## Create a new Database Migration
Open the **Package Manager Console** on Visual Studio and ensure that the **Default project** is `Acme.BookStore.EntityFrameworkCore.DbMigrations` in the Package Manager Console, as shown on the picture below. Also, set this project as the **startup project** (right click it on the solution explorer and click to "Set as Startup Project").
The startup solution is configured to use [Entity Framework Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). Since we've changed the database mapping configuration, we should create a new migration and apply changes to the database.
Run the following command to create a new database migration:
Open a command-line terminal in the directory of the `Acme.BookStore.EntityFrameworkCore.DbMigrations` project and type the following command:
````bash
Add-Migration "Added_Authors"
dotnet ef migrations add Added_Authors
````
![bookstore-add-migration-authors](images/bookstore-add-migration-authors.png)
This will add a new migration class to the project:
This will create a new migration class. Then run the `Update-Database` command to create the table on the database.
![bookstore-efcore-migration-authors](./images/bookstore-efcore-migration-authors.png)
> See the [Microsoft's documentation](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/) for more about the EF Core database migrations.
You can apply changes to the database using the following command, in the same command-line terminal:
````bash
dotnet ef database update
````
> If you are using Visual Studio, you may want to use `Add-Migration Added_Authors -c BookStoreMigrationsDbContext` and `Update-Database -c BookStoreMigrationsDbContext` commands in the *Package Manager Console (PMC)*. In this case, ensure that {{if UI=="MVC"}}`Acme.BookStore.Web`{{else if UI=="BlazorServer"}}`Acme.BookStore.Blazor`{{else if UI=="Blazor" || UI=="NG"}}`Acme.BookStore.HttpApi.Host`{{end}} is the startup project and `Acme.BookStore.EntityFrameworkCore.DbMigrations` is the *Default Project* in PMC.
{{else if DB=="Mongo"}}

BIN
docs/en/Tutorials/images/bookstore-efcore-migration-authors.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
docs/en/Tutorials/images/bookstore-efcore-migration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

16
docs/zh-Hans/Tutorials/Part-1.md

@ -185,23 +185,19 @@ namespace Acme.BookStore.EntityFrameworkCore
### 添加数据迁移
启动模板使用[EF Core Code First Migrations](https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/)创建和维护数据库架构. 打开菜单*工具 > NuGet包管理器*下的**程序包管理控制台 (PMC)**.
启动模板使用[EF Core Code First Migrations](https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/)创建和维护数据库架构. 我们应该创建一个新的迁移并且应用到数据库.
![Open Package Manager Console](images/bookstore-open-package-manager-console.png)
选择 `Acme.BookStore.EntityFrameworkCore.DbMigrations` 做为**默认项目**然后执行以下命令:
在 `Acme.BookStore.EntityFrameworkCore.DbMigrations` 目录打开命令行终端输入以下命令:
```bash
Add-Migration "Created_Book_Entity"
dotnet ef migrations add Created_Book_Entity
```
![bookstore-pmc-add-book-migration](./images/bookstore-pmc-add-book-migration-v2.png)
它会在 `Acme.BookStore.EntityFrameworkCore.DbMigrations` 项目中的 `Migrations` 文件内创建一个新的迁移类.
它会添加新迁移类到项目中:
在更新数据库之前,请阅读下面的部分了解如何将一些初始数据插入到数据库.
![bookstore-efcore-migration](./images/bookstore-efcore-migration.png)
> 如果你使用其他IDE而不是Visual Studio, 你可以使用 [`dotnet-ef`](https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-a-migration) 工具.
> 如果你使用Visual Studio, 你也许想要在*包管理控制台(PMC)*中使用 `Add-Migration Created_Book_Entity -c BookStoreMigrationsDbContext` 和 `Update-Database -c BookStoreMigrationsDbContext` 命令. 确保 {{if UI=="MVC"}}`Acme.BookStore.Web`{{else if UI=="BlazorServer"}}`Acme.BookStore.Blazor`{{else if UI=="Blazor" || UI=="NG"}}`Acme.BookStore.HttpApi.Host`{{end}} 是启动项目并且 `Acme.BookStore.EntityFrameworkCore.DbMigrations` 是 PMC 的*默认项目*.
{{end}}

BIN
docs/zh-Hans/Tutorials/images/bookstore-efcore-migration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Loading…
Cancel
Save