Asset¶
For services like Service Order, or Inspections, we need a way of abstracting from the actual "things" or "places" we are performing maintenance against, or inspections.
Asset is an abstract concept it may be a Soda Machine, a Stateroom, a Restaurant, a Corridor, etc.
Currently, the Suite includes Locations and Components as independent concepts. An Asset is a materialized view of those.
Asset Client Module¶
An AssetClientModule
is provided in order to allow other services to integrate
with this concept. The module includes the Asset
entity, it's EF Core
mappings, and is kept in sync with Components and Locations.
How to use it¶
The main idea behind the AssetClientModule
is that you create your own entity
(i.e ServiceOrder
) and can have relations to an entity Asset
which is
provided by the module.
The DB structure is included as your own service's migrations, and it is handled as another regular entity. The only difference is that we can share the class and it's mapping so that you don't need to write them!
Defining an entity with an asset¶
First we need to reference the AssetClientModule
's Abstraction assembly from
our Domain layer.
XML | |
---|---|
This will allow us to create an entity which has an Asset
:
C# | |
---|---|
We then need to add an EntityTypeConfiguration for this entity on our Persistence layer as usual:
After doing that, we must reference and configure the AssetClientModule
on our
Application Module before we can generate migrations.
Configuring the Application Module¶
First we have to include the AssetClientModule
reference in your Application
layer csproj:
XML | |
---|---|
Afterwards, we need to DependOn
and configure our AssetClientModule
in our
service's Application Module:
We can now generate migrations for our service as usual, and we should see the one to one relation we just added, and the table for Assets being created.
You can then use the entities as usual.