Dapper.Contrib icon indicating copy to clipboard operation
Dapper.Contrib copied to clipboard

GetAll<T> only supports an entity with a single [Key] or [ExplicitKey] property. [Key] Count: 0, [ExplicitKey] Count: 2

Open gandarez opened this issue 4 years ago • 6 comments

[Table("MyTable")]
public class TableEntity
{
    [ExplicitKey]
    public string Name { get; set; }
    [ExplicitKey]
    public Guid Id { get; set; }
}

The error happens when calling

return await GetAllAsync<MyTable>();

gandarez avatar Nov 21 '19 17:11 gandarez

me too

winhoals avatar Aug 20 '20 06:08 winhoals

I'm running into this as well. I have a table with a composite key. Hope this gets some attention soon.

jakehockey10 avatar May 17 '21 17:05 jakehockey10

I've got this problem, too

SuperJMN avatar May 20 '21 21:05 SuperJMN

Same issue

sk0va avatar Mar 24 '22 19:03 sk0va

Same problem

asilvestrosipos avatar Jun 24 '22 13:06 asilvestrosipos

using Dapper.Contrib.Extensions;

[Table("MyTable")]
public class TableEntity
{
    [Key]
    public Guid Id { get; set; }
 
    public string Name { get; set; }
}

Check your library of the [ExplicitKey] and try adding [Key] to Guid only.

Library of the key must be Dapper.Contrib.Extensions;

corsantic avatar May 02 '24 13:05 corsantic