csharpfritz / InstantAPIs

A library that generates Minimal API endpoints for an Entity Framework context.
MIT License
448 stars 57 forks source link

MapInstantAPIs fails when Dbset properties with [Keyless] attribute #69

Closed anuraj closed 1 year ago

anuraj commented 2 years ago

I was trying to generate Minimal APIs for the Northwind database. I generated the entities with dotnet ef scaffold command with data annotation support. After scaffolding some entities generated with Keyless attribute.

[Keyless]
public partial class CategorySalesFor1997
{
    [StringLength(15)]
    public string CategoryName { get; set; } = null!;
    [Column(TypeName = "money")]
    public decimal? CategorySales { get; set; }
}

When I run the application - MapInstantAPIs failed with KeyNotFoundException.

image

I think we should skip the tables with the Keyless attribute.