Support insertion of keyless entities
See original GitHub issueI’ve got a case where I’m writing time series data to a postgresql database. In mapping an Entity that represents a record in a time series table, I’ve explicitly and purposely forgone an ID field, because it’d likely overflow, and wont be used for anything in the future. (there are indexes there to help with querying, but they are specific to postgres/timescaledb).
I’ve marked the entity with [Keyless]
and understand why the entity can’t be tracked, but I am confused by why entity framework couldn’t handle deletes and explicit inserts, and just fail to do an update where necessary. Can I turn off tracking for a specific DbSet
or something, be able to take advantage of querying, inserts, and deletes?
Is there anyway to work around it and be able to write data with no id column to the the db, without having to manually write a bunch of parameterized insert statements?
Is there any likelihood of this being changed or improved in the future?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
@ronnyek this is definitely something we intend to support.
Removing from the backlog as this is basically a dup of #29897.
Working on a completely separate project, totally different needs and I find myself needing this exact same thing again. Writing timeseries data that I can map and query as keyless, but cant insert. In my case I’m using npgsql and timescaledb, and timescale handles archiving/aggregation building etc. The closest thing to a key that I’d want would be the timestamp metric.
I get how keyless insert could be problematic with tracking and updates would be even more difficult, I don’t feel like I should have to revert to totally manual queries for writing… because efcore knows how to do this stuff already.
Inserts and tracking I get, but my specific use case I wont be fetching a record, and updating it. Infact I will be unlikely to ever update these keyless records.
So now I have to basically create/add an id column that I will never use taking up space…