Repositories-Ifaces.tt
1. Update the input arguments
Update the paths and namespace names at the top of the text template script according to your project.
var targetPath = Host.ResolvePath("../../../KLO128.D3ORM.Sample.Domain/Repositories/");
var entitiesJsonPath = Host.ResolvePath("EntitiesFromEFCore.tt").Replace(".tt", ".json");
DefaultNameSpace = "KLO128.D3ORM.Sample.Domain.Repositories";
EntitiesNameSpace = "KLO128.D3ORM.Sample.Domain.Models.Entities";
DatabaseContextNames = new string [] {"D3ORMSampleContext"};
- targetPath is the folder path where the repository interfaces are generated or overwritten in.
- entitiesJsonPath is the configuration file path of the aggregations - necessary for determination if to extend ICommonRepository or IAggRootRepository. If not specified or not found, IAggRootRepository is used as the base interface.
- DefaultNameSpace is the namespace of the generated (target) interface.
- EntitiesNameSpaceis the namespace of the entities.
- DatabaseContextNames is an array of the local class/interface names without .cs suffix which should be excluded from the generation - typically EF Core DbContext.
2. Run the Text Template Script
Run the text template to generate repository interfaces for all entities.
Example
///
/// generated file 01.09.2022 9:21:20
///
using System;
using KLO128.D3ORM.Common.Abstract;
using KLO128.D3ORM.Website.Domain.Models.Entities;
namespace KLO128.D3ORM.Website.Domain.Repositories
{
public interface IUserRepository : IAggRootRepository<User>
{
}
}