EntityFrameworkCore.Generator icon indicating copy to clipboard operation
EntityFrameworkCore.Generator copied to clipboard

Error naming Validators

Open fpizarro opened this issue 6 years ago • 3 comments

Hi.. when I run efg generate, the validators classes are finishing with number one (1). This is the Validator section in my generation.yml file

validator: generate: true name: '{Entity.Name}Validator' baseClass: AbstractValidator<{Model.Name}> namespace: '{Project.Namespace}.Application.Validators' directory: '{Project.Directory}\MyApplication.Application\Validators'

CustomerValidator1.cs ColorValidator1.cs

Thanks for your help!

fpizarro avatar Apr 23 '19 17:04 fpizarro

A number is added when there is a duplicate class name. Is there another class with the same name?

pwelter34 avatar Apr 23 '19 18:04 pwelter34

Thanks for your response. No... there is no other classes with the same name in this folder. I tried deleting and changing the folder, I also tried generating a different class name but the problem persist.

Something about the ending characters in the last line in the .yml file?

fpizarro avatar Apr 23 '19 19:04 fpizarro

Hi... doing some tests I reproduce the problem... when I assign true to generate in the Read section the validation class name finish with one (1). Here is my .yml file

project: namespace: 'MyApplication' directory: .
database: connectionName: ConnectionStrings:MyApplication userSecretsId: 9556eaab-e273-4781-9ae0-c876913ff363 tables: [] schemas: [] data: context: name: 'MyApplicationDbContext' baseClass: DbContext namespace: '{Project.Namespace}.Persistence' directory: '{Project.Directory}\MyApplication.Persistence' entity: namespace: '{Project.Namespace}.Domain.Entities' directory: '{Project.Directory}\MyApplication.Domain\Entities' mapping: namespace: '{Project.Namespace}.Persistence.Configurations' directory: '{Project.Directory}\MyApplication.Persistence\Configurations' query: generate: false indexPrefix: By uniquePrefix: GetBy namespace: '{Project.Namespace}.Domain.Queries' directory: '{Project.Directory}\Domain\Queries' model: shared: namespace: '{Project.Namespace}.Application.Entities' directory: '{Project.Directory}\MyApplication.Application\Entities' include: entities: [] properties: [] exclude: entities: [] properties: [] read: generate: true name: '{Entity.Name}ReadModel' include: entities: [] properties: [] exclude: entities: [] properties: [] create: generate: true name: '{Entity.Name}Command' include: entities: [] properties: [] exclude: entities: [] properties: [] update: generate: false name: '{Entity.Name}Update' include: entities: [] properties: [] exclude: entities: [] properties: [] mapper: generate: true name: '{Entity.Name}Profile' baseClass: AutoMapper.Profile namespace: '{Project.Namespace}.Application.Mapping' directory: '{Project.Directory}\MyApplication.Application\Mapping' validator: generate: true name: '{Entity.Name}Validation' baseClass: AbstractValidator<{Model.Name}> namespace: '{Project.Namespace}.Application.Validators' directory: '{Project.Directory}\MyApplication.Application\Validators'

fpizarro avatar Apr 23 '19 19:04 fpizarro