schotime / NPoco

Simple microORM that maps the results of a query onto a POCO object. Project based on Schotime's branch of PetaPoco
Apache License 2.0
848 stars 302 forks source link

Are Composite Keys Still Supported? #672

Closed markadrake closed 2 years ago

markadrake commented 2 years ago

Versions:

NPoco 5.3.2 NPoco.SqlServer 5.3.2 Microsoft.Data.SqlClient 3.0.0

Sample Class:

[TableName("Example")]

[PrimaryKey("One,Two")]

public class Example {

  public int One {get;set;}

  public int Two {get;set;}

}

Expectation:

I would expect the table Example to include a Primary Key comprised of both columns One and Two.

I'm using this code with the Umbraco CMS. There could be an issue in Umbraco.CMS.Infrastructure.Migrations.Expressions.Common that is not handling the composite key when the table is created. I'd greatly appreciate it if someone can help me confirm my approach is right/wrong before I open a ticket there. Thank you!

Result:

image

Wiki Reference:

I built the example code above using the following Wiki page as a reference.

markadrake commented 2 years ago

I'm closing this issue. Whatever problems I'm having with the composite primary key, it's between my code and the Umbraco CMS. I've successfully tested NPoco in a separate project. TY, and sorry for the trouble!