Generating a CRUD page
When you add an existing project or create a new one, the project will be listed in the "Open Recent" section. To select the project, click on the project name.
Be aware that, ABP Suite generates a unique URL for every project. After you select your project, you can safely bookmark it to your browser to access it faster.
Entity info
To create a new entity, make sure the -New entity- is selected in the Entity combo box which is on the top-right of the page. In this section, you need to provide the meta data of your entity. Do not use C# reserved keywords for your entity name, plural name, database table name or the namespace.
Name: Name of the entity.
Plural Name: Folder names of the entity and name of
DbSet
in theDbContext
.Database table/collection name: Name of the database table for relational databases or name of the collection name for NoSQL databases.
Namespace: Namespaces of the entities, DTOs and other
C#
classes.Base class: There are several base classes that comes out of the box from the ABP Framework. Basically there are 2 main types of entity.
AggregateRoot
and simpleEntity
. And these two have 2 more variants withAudited
andFullAudited
derivatives.If your entity consists of child entities like an
Order
with itsOrderDetail
entities, then you should choose AggregateRoot / AuditedAggregateRoot / FullAuditedAggregateRoot.If it doesn't have any child entities like a
City
entity, you can choose Entity / AuditedEntity / FullAuditedEntityEntity and AggregateRoot are the low-level simple base classes.
AuditedEntity and AuditedAggregateRoot adds these fields to the entity:
CreationTime
CreatorId
LastModificationTime
LastModifierId
Hence, it keeps track of who created and changed the data with the date time information.
FullAuditedEntity and FullAuditedAggregateRoot adds these fields to the entity:
CreationTime
CreatorId
LastModificationTime
LastModifierId
IsDeleted
DeleterId
DeletionTime
It extends the audited entity features with soft delete functionality. When the data is deleted, it sets the
IsDeleted
field totrue
instead of physically removing it. The ABP Framework automatically filters the soft deleted data on data fetch. Also it saves who and when deleted.
Primary key type: Primary key is a field in a table or collection which uniquely identifies each record. ABP Suite allows you to create an entity with one of the 4 types:
Int
,Long
,Guid
andString
. ABP Suite recommendsGuid
because,- You can identify objects at the application level.
- You can generate
IDs
anywhere, instead of having to roundtrip to the database. - Better migration and replication! When working with other databases it's easy to migrate data with all its child entities because unique across every table, database and server.
- Allows easy distribution of databases across multiple servers
- The performance is not bad as
String
because database systems handleGuids
nicely. - It's being generated as sequentially by the ABP Framework, so that the physical order of the data in your database will be creation order.
Guids
use 16 bytes. When comparing toInt
as 4 bytes, additional 12 bytes do come at a cost.
On the other hand
Int
andLong
types have some other advantages:- Small storage footprint
- Optimal join / index performance
- Useful for data warehousing
- Native data type of the OS and easy to work with in all languages
Multi-tenant: For your multi-tenant application, you can set an entity as multi-tenant which means the data will be isolated between the tenants. To make an entity multi-tenant, ABP Suite adds the
IMultiTenant
interface to the entity. Further information see Multi-TenancyAdd migration: Adds a new migration for the new entity. If you are updating an existing entity, it creates an update migration.
- Update database: When you add a new migration, ABP Suite can automatically execute update-database command so that the changes are being applied to the database.
Create user interface: Creates pages, modals, components,
JavaScript
,CSS
files and adds the new page to the main menu. If you don't have a requirement to manage the entity via user interface, you can uncheck this option.
Properties
Define a property
A property is a field in the entity which refers a column in the relational database table or a JSON
field in NoSQL
database collection. In the properties section, you can manage the properties your entity. To add a new property, click the "Add Property" button on the top-right of the page.
- Property name: Name of the field. Do not use C# reserved keywords and database reserved keywords.
- Property type: Choose a relevant property type from the list.
- Min-Max length: These values are used to limit the data value. The length of the database column will also be created by taking this number into consideration. ABP validates the data on the client and server side according to these values.
- Required: Defines whether a value is required or not.
- Nullable: Allows you to set the property as
nullable
for theC#
supported data types.
Property list
The list of all properties defined for the entity. You can delete or edit a property.
Sorting
You can use sorting field column to specify or change the order in which results are sorted. To arrange sorting, click the first combo box (Sort Index
) that you want to set order index. Choose Ascending
or Descending
to specify the sort order for the column.
Navigation Properties
A navigation property is a foreign key field in the entity which holds the primary key of another entity.
Define a navigation property
- Entity namespace: Namespace of the entity you want to use as navigation property.
- Entity name: Name of the entity.
- Entity collection name: Collection name of the entity in DbContext.
- Dto namespace: Namespace of Dto object of the entity.
- Dto name: Name of Dto object of the entity.
- Primary key: Primary key type of the entity.
- Property name: Name of the (reference) property that will be created in main entity.
- Display property: Name of the property, that belongs to and exist in the entity you want to use as navigation property, that will be used in interface as display name. It must be a string.
- Ui pick type: Determinates how the relation between entities will be set in user interface. Modal: A paged table inside a modal will allow you to select a navigation property. Dropdown: A dropdown will allow you to select a navigation property.
In an example scenario, we are creating a Student entity and adding a navigation property to existing Teacher entity. See screeshots below:
Saving
There are 2 action to save the entity.
Save as draft
Saves only the entity and not generates any code. This is useful when you don't want to apply changes to your project.
Save and generate
Saves the entity and generates related code. Your project will be updated.
Database table
When you click Save and generate button it'll create all the related objects. The below screenshot is the MS SQL database table that's generated via ABP Suite.