Skip to content

[FYI] Issue when using MSSQL on the CommandsService Project #18

@darsenault77

Description

@darsenault77

For those like me that went the MSSQL route on the CommandsService Project instead of keeping it in memory, you will most likely run into an issue with inserting a platform in the EventProcessor that does not happen when using in memory.

The mapping used for PlatformPublishedDto

CreateMap<PlatformPublishedDto, Platform>()
                .ForMember(dest => dest.ExternalId, opt => opt.MapFrom(src => src.Id));

while mapping the PlatformService's PlatformPublishedDto.Id to a CommandsService's PlatformPublishedDto.ExternalId , it will leave the same PlatformService's PlatformPublishedDto.Id also mapped to the CommandsService's PlatformPublishedDto.Id

That will cause MSSQL to complain about inserting with an explicit IDENTITY.

To fix this, you have to tell AutoMapper to ignore Id on the destination like below:

CreateMap<PlatformPublishedDto, Platform>()
                .ForMember(dest => dest.ExternalId, opt => opt.MapFrom(src => src.Id))
                .ForMember(dest => dest.Id, opt => opt.Ignore());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions