You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using .NET 7.0, AgileMapper 1.8.1, EF Core 7.0.1
I have an entity class (code-first) called Document that has a primary key DocumentId (int) and a property Id (string).
With code-first I had to add entity.HasKey(x => x.DocumentId); to make DocumentId PK, else it defaulted to Id as PK.
I also have a DocumentDto without DocumentId, only Id.
But when running a query projecting to DocumentDto, I notice that the Id in the dto is getting the value from DocumentId!
I tried to correct this by creating an explicit mapping in a MappingConfiguration class, but then I got an exception telling me that the mapping was unnecessary.
I logged the generated query, and here it is converting DocumentId AS Id!
SELECTCONVERT(varchar(11), [d].[DocumentId]) AS [Id], [d].[Description], [d].[CreatedDate]
FROM [Document] AS [d]
Why is it doing this? This must be a bug!
However, I've managed to workaround this by having this mapping in the Project().To() config:
Using .NET 7.0, AgileMapper 1.8.1, EF Core 7.0.1
I have an entity class (code-first) called Document that has a primary key DocumentId (int) and a property Id (string).
With code-first I had to add
entity.HasKey(x => x.DocumentId);
to make DocumentId PK, else it defaulted to Id as PK.I also have a DocumentDto without DocumentId, only Id.
But when running a query projecting to DocumentDto, I notice that the Id in the dto is getting the value from DocumentId!
I tried to correct this by creating an explicit mapping in a MappingConfiguration class, but then I got an exception telling me that the mapping was unnecessary.
I logged the generated query, and here it is converting DocumentId AS Id!
Why is it doing this? This must be a bug!
However, I've managed to workaround this by having this mapping in the Project().To() config:
With this, the query becomes as expected
The text was updated successfully, but these errors were encountered: