0

So this is a question about Serialization and Versioning. I have a program that is a Music database that stores sheet music with Name, Composer, ... I serialize each song to a hidden folder so that the user can reload the database at next launch.

Now, when I have to change something in the Song class all is fine if it is a compatible change. I had the idea that if I were to make an incompatible change, would I be able to create a second class with the same name 'Song' but a different VersionUID. Then when it reads the Songs, if the saved version doesn't match the latest version, it will go to a method that will read the Song into the old UID then go through a series of steps to convert it to the new Version. Is any of this possible?

I do know that you can have multiple methods with the same name but different parameters. Would this work with classes and VersionUID's or some other variable?

Thanks!

Jack
  • 15
  • 1
  • 4

1 Answers1

0

No it would not. Classes do not support a concept like "property overload" so a class with the same name is considered as the same class, even if it has different properties.

The "best" way for you would be a migration to a relational database in combination with EntityFramework6 (there is a SQLite adapter out there, so you don't need SQLServer). With EF you can use migrations which enables you to change your model and migrate the data automatically. If done correctly you can change the model and no data loss occurs.

Ruhrpottpatriot
  • 1,058
  • 3
  • 17
  • 31