Skip to content
Discussion options

You must be logged in to vote

@robinfehr

I would do this by putting all the migration logic in a method on the entity, and call this migration method at the start of every one of the existing entity interface methods.

public Task Foo() {
     MigrateToV1()
     // your normal 'Foo' entity code here
}

public Task<bool> Bar(string data) {
     MigrateToV1()
     // your normal 'Bar' entity code here
}

The migration method would first check a new version property (don’t forget to include this in the entity state) that is introduced in the new entity code.

[JsonProperty("version")]
public int Version {get; set; }

private void MigrateToV1() {
     if (Version < 1)
     {
           // upgrade your entity to V1

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by cgillum
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1650 on April 01, 2021 17:35.