diff --git a/docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order-v2.png b/docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order-v2.png new file mode 100644 index 0000000000..6a955db66f Binary files /dev/null and b/docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order-v2.png differ diff --git a/docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order.png b/docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order.png deleted file mode 100644 index b739e59373..0000000000 Binary files a/docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order.png and /dev/null differ diff --git a/docs/en/tutorials/modular-crm/images/sql-server-orders-database-table-v2.png b/docs/en/tutorials/modular-crm/images/sql-server-orders-database-table-v2.png new file mode 100644 index 0000000000..c93de086f4 Binary files /dev/null and b/docs/en/tutorials/modular-crm/images/sql-server-orders-database-table-v2.png differ diff --git a/docs/en/tutorials/modular-crm/images/sql-server-orders-database-table.png b/docs/en/tutorials/modular-crm/images/sql-server-orders-database-table.png deleted file mode 100644 index 2090a35673..0000000000 Binary files a/docs/en/tutorials/modular-crm/images/sql-server-orders-database-table.png and /dev/null differ diff --git a/docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2-v2.png b/docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2-v2.png new file mode 100644 index 0000000000..fe9780c345 Binary files /dev/null and b/docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2-v2.png differ diff --git a/docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2.png b/docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2.png deleted file mode 100644 index c5a698db58..0000000000 Binary files a/docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2.png and /dev/null differ diff --git a/docs/en/tutorials/modular-crm/images/visual-studio-order-entity-v2.png b/docs/en/tutorials/modular-crm/images/visual-studio-order-entity-v2.png new file mode 100644 index 0000000000..47435ab2b9 Binary files /dev/null and b/docs/en/tutorials/modular-crm/images/visual-studio-order-entity-v2.png differ diff --git a/docs/en/tutorials/modular-crm/images/visual-studio-order-entity.png b/docs/en/tutorials/modular-crm/images/visual-studio-order-entity.png deleted file mode 100644 index 112ee3d7d3..0000000000 Binary files a/docs/en/tutorials/modular-crm/images/visual-studio-order-entity.png and /dev/null differ diff --git a/docs/en/tutorials/modular-crm/part-03.md b/docs/en/tutorials/modular-crm/part-03.md index 454700b186..9a5fb55721 100644 --- a/docs/en/tutorials/modular-crm/part-03.md +++ b/docs/en/tutorials/modular-crm/part-03.md @@ -45,6 +45,8 @@ public class Product : AggregateRoot } ```` +> Note that in this tutorial, we create classes directly in the project's root folder to keep things simple. It is up to you to create subfolders (namespaces) in your project to achieve finer code organization, especially for large modules. + ## Mapping Entity to Database The next step is to configure the Entity Framework Core `DbContext` class and the database for the new entity. @@ -182,13 +184,13 @@ public class ModularCrmDbContext : } ```` -**(3)** Finally, ensure that the `ConfigureCatalog()` extension method is called inside the `OnModelCreating` method (this should be already done because you set the _Setup as a modular solution_ option in the _Modularity_ step while creating the initial solution): +**(3)** Finally, ensure that the `ConfigureCatalog()` extension method is called inside the `OnModelCreating` method (this should be already done because you set the _Setup as a modular solution_ option in the _Modularity_ step while creating the initial solution). In this way, `ModularCrmDbContext` can be used by the catalog module over the `ICatalogDbContext` interface. This part is only needed once for a module. Next time, you can directly add a new database migration, as explained in the next section. #### Add a Database Migration -Now, you can add a new database migration. You can use Entity Framework Core's `Add-Migration` (or `dotnet ef migrations add`) terminal command, but we will use ABP Studio's shortcut UI in this tutorial. +You can use Entity Framework Core's `Add-Migration` (or `dotnet ef migrations add`) terminal command, but we will use ABP Studio's shortcut UI in this tutorial. Ensure that the solution has built. You can right-click the `ModularCrm` (under the `main` folder) on ABP Studio *Solution Runner* and select the *Dotnet CLI* -> *Graph Build* command. diff --git a/docs/en/tutorials/modular-crm/part-05.md b/docs/en/tutorials/modular-crm/part-05.md index 9767bb0bec..4553b0c7a9 100644 --- a/docs/en/tutorials/modular-crm/part-05.md +++ b/docs/en/tutorials/modular-crm/part-05.md @@ -14,7 +14,7 @@ } ```` -In the previous part, you created Ordering module and installed it into the main application. However, the Ordering module has no functionality now. In this part, you will create an `Order` entity and add functionality to create and list the orders. +In the [previous part](part-04), you created Ordering module and installed it into the main application. However, the Ordering module has no functionality yet. In this part, you will create an `Order` entity and add functionality to create and list the orders. ## Creating an `Order` Entity @@ -24,14 +24,13 @@ Open the `ModularCrm.Ordering` .NET solution in your IDE. ### Adding an `Order` Class -Create an `Order` class to the `ModularCrm.Ordering` project (open an `Entities` folder and place the `Order.cs` into that folder): +Create an `Order` class to the `ModularCrm.Ordering` project: ````csharp using System; -using ModularCrm.Ordering.Contracts.Enums; using Volo.Abp.Domain.Entities.Auditing; -namespace ModularCrm.Ordering.Entities; +namespace ModularCrm.Ordering; public class Order : CreationAuditedAggregateRoot { @@ -41,14 +40,14 @@ public class Order : CreationAuditedAggregateRoot } ```` -We allow users to place only a single product within an order. The `Order` entity would be much more complex in a real-world application. However, the complexity of the `Order` entity doesn't affect modularity, so we keep it simple to focus on modularity in this tutorial. We are inheriting from the [`CreationAuditedAggregateRoot` class](../../framework/architecture/domain-driven-design/entities.md) since I want to know when an order has been created and who has created it. +We allow users to place only a single product within an order. The `Order` entity would be much more complex in a real-world application. However, the complexity of the `Order` entity doesn't affect modularity. So, we keep it simple to focus on modularity in this tutorial. We are inheriting from the [`CreationAuditedAggregateRoot` class](../../framework/architecture/domain-driven-design/entities.md) since I want to know when an order has been created and who has created it. ### Adding an `OrderState` Enumeration -You used an `OrderState` enumeration that has not yet been defined. Open an `Enums` folder in the `ModularCrm.Ordering.Contracts` project and create an `OrderState.cs` file inside it: +We used an `OrderState` enumeration that has not yet been defined. Create a `OrderState.cs` file inside the `ModularCrm.Ordering.Contracts` project and define the following Enum: ````csharp -namespace ModularCrm.Ordering.Contracts.Enums; +namespace ModularCrm.Ordering; public enum OrderState : byte { @@ -60,7 +59,7 @@ public enum OrderState : byte The final structure of the Ordering module should be similar to the following figure in your IDE: -![visual-studio-order-entity](images/visual-studio-order-entity.png) +![visual-studio-order-entity](images/visual-studio-order-entity-v2.png) ## Configuring the Database Mapping @@ -202,19 +201,21 @@ Right-click the `ModularCrm` package and select the *EF Core CLI* -> *Add Migrat The *Add Migration* command opens a new dialog to get a migration name: -![abp-studio-entity-framework-core-add-migration-order](images/abp-studio-entity-framework-core-add-migration-order.png) +![abp-studio-entity-framework-core-add-migration-order](images/abp-studio-entity-framework-core-add-migration-order-v2.png) Once you click the *OK* button, a new database migration class is added to the `Migrations` folder of the `ModularCrm` project: -![visual-studio-new-migration-class-2](images/visual-studio-new-migration-class-2.png) +![visual-studio-new-migration-class-2](images/visual-studio-new-migration-class-2-v2.png) Now, you can return to ABP Studio, right-click the `ModularCrm` project and select the *EF Core CLI* -> *Update Database* command: ![abp-studio-entity-framework-core-update-database](images/abp-studio-entity-framework-core-update-database.png) -After the operation completes, you can check your database to see the new `Orders` table has been created: +After the operation completes, you can check your database to see the new `OrderingOrders` table has been created: + +![sql-server-products-database-table](images/sql-server-orders-database-table-v2.png) -![sql-server-products-database-table](images/sql-server-orders-database-table.png) +`Ordering` prefix is added to all table names of the Ordering module. If you want to change or remove it, see the `OrderingDbProperties` class in the Ordering module's .NET solution. ## Creating the Application Service