Kosmik
Honorary Master
Alright I ditched contoso and any other database I was trying and headed straight for AdventureWorks. Was getting the same issue.
I tried key and explicitkey to no avail however what did fix it was having to use a fully qualifying table name as they are shown in AdventureWorks. Why Microsoft did this database that way is a mystery to me
Edit: I've updated Github. Nowhere near finished but at least getting some joy.
C#:[Table("Person.Person")] public class Person { [ExplicitKey] public int BusinessEntityID { get; set; } public string PersonType { get; set; } public bool NameStyle { get; set; } public string Title { get; set; } public string FirstName { get; set; } public string MiddleName { get; set; } public string LastName { get; set; } public string Suffix { get; set; } public int EmailPromotion { get; set; } public string AdditionalContactInfo { get; set; } public string Demographics { get; set; } }
![]()
For other databases it would likely be dbo.Person
Hehe, I can see your issue. It's the singular/plural conundrum I spoke about.
To find the right table name, Dapper Contrib either expects a Table attribute or assumes a pluralized table name.
You don't need to state dbo.Person but because your classname is Person, contrib is expecting a table name of Persons. I'm not sure what the default behaviour is for multiple schemas though ie: schema.Table, or if contrib will detect a correct scheme.pluralizedTable.
Its an old dev argument.
The table naming dilemma: singular vs. plural
The other day, while in a planning poker session, the question of the naming of a particular table arose. During that conversation, one of…
Plural vs Singular Table Name
How should I name my Tables when creating a new database? Singular: Client or Plural: Clients?
Naming standards? Singular or Plural
It’s important that for any software application good standards exist. Standards ensure a number of key considerations. Standards are necessary to enforce and provide reproducible software and to provide a level of quality in a team environment, ease of readability and consistency.
Last edited: