-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cosmos: Configure TTL per entity/entity type/container #17307
Comments
Hi Team, Is there any update on this? We need to set TTL at item level but it can work only if it is configured at container level and I couldn't find any method in efcore 3.1.1 that sets TTL value at container level. Any help would be much appreciated Thank you |
@pavitrag123 No work has been done for this yet. Vote 👍 on the first post for the features that you think should be prioritized. |
Let's make it up-for-grabs. |
@Marusyk We don't use the up-for-grabs label anymore, you can submit a PR for any issue. But at this point we aren't accepting external PRs for 5.0 anymore, it would need to target |
Would it be possible to link where in the documentation this new functionality is explained? Couldn't find it at first glance. |
There's a sample at https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/whatsnew#configure-time-to-live I've created dotnet/EntityFramework.Docs#3730 to track this |
@AndriySvyryd the sample you provided only shows a fixed, container-scoped value. I wanted to setup a "per entry" TTL value without a container default value (the "On (no default)" option). Is there a way to also do that, or does EF only support changing this setting at model building time? I assume it's the former, in which case a very basic outline of how it works would be fine while I wait for the full documentation. I have a project coming up where we'll allow the user to provide an expiration date that will then be the source for Cosmos TTL, so it would be essential to know whether this is possible or not. |
You'd need to do something like modelBuilder.Entity<MyEntity>().HasDefaultTimeToLive(3600).Property<int>("Ttl").ToJsonProperty("ttl"); And then context.Entry(myEntity).Property<int>("Ttl").CurrentValue = 60 You can also use a non-shadow property to make the code simpler. |
To specify a TTL value for a given item the entity type must have a property mapped to "ttl" and the corresponding container must have a non-null TTL
The text was updated successfully, but these errors were encountered: