Adding an entity and the related infrastructure is a multi-step affair. We'll assume the type you are adding below is Chronoton for illustrative purposes.
- Create a domain model in
Domain/GRA.Domain.Model.
- Generally this object should inherit
Abstract.BaseDomainEntity.
- Create a data model in
Infrastructure/GRA.Data/Model.
- Generally this object should inherit
Abstract.BaseDbEntity. - Inheriting
Abstract.BaseDbEntityis appropriate if the primary key is an identityintcolumn (seeGRA.Data.Model.UserRolefor an example of a type with a composite key).
- Add the type to the
GRA.Data/Context.csfile in the appropriate place (alphabetically).
- If any composite keys or indexing is necessary, add them in the appropriate places.
- Add an AutoMapper map in
Infrastructure/GRA.Data/Profile/MappingProfile.cs. - Create an interface for the repository in
Domain/GRA.Domain.Repository.
- Remember to make it
public. - Inherits
IRepository<Model.Chronoton>. - Named
IChronotonRepository.
- Create the repository in
GRA.Data/Repositorydirectory.
- Inherits
AuditingRepository<Model.Chronoton, Domain.Model.Chronoton>. - Implements
IChronotonRepository. - If you right-click on the repository type to allow Visual Studio to generate a constructor, ensure you modify the
ILoggerto add the generic (e.g.ILogger<ChronotonRepository>). Also remember to reformat to < 100 characters per line.
- Create the service in
GRA.Domain.Service.
- Keep in mind you might not name this service
ChronotonServiceas it should serve the domain needs. - It should inherit
Abstract.BaseService<ChronotonService>.
- Add the service and repository (in the appropriate alphabetical location) to the DI configuration in
GRA.Web/Startup.cs.