Orleans IPersistentState POCO Namespace/Class Library Versioning problems #9085
-
Hi everyone. First of all thanks for this amazing project that I'm in love since I heard about it some years ago. I'm building a server app, and the only problems I'm facing is when I'm refactoring Grain IPersitentState POCO objects like this:
This POCO object is in thenamespace
Whenever I write to the state it is persisted properly to the SQL Server database, and I can see the JSON from the
I can see there that both the However, I have been heavily refactoring the model classes and I have changed them from the old namespace to
Worth reiterating again, that if I do not change the Is there any kind of good practice around this problem? What I have thouth is on adding the Orleans PersistentState classes to the same isolated Orleans library under a short fixed namespace Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @zharchimage, Orleans.Serialization is not used by default for storage, so what you're setting is the result of Newtonsoft.Json (the default) being used and not coping with the name change. Newtonsoft.Json also has a mechanism for that called a [ContractResolver] (https://www.newtonsoft.com/json/help/html/ContractResolver.htm) EDIT to clarify: the GenerateSerializer/Id/Alias attributes are used by Orleans.Serialization, which is used for RPC and optionally for storage. It can be used for storage serialization by adding it to DI using |
Beta Was this translation helpful? Give feedback.
Hi, I did some research and had to change the Json configuration as you suggested. Apparently there is a flag in the
JsonSerializerSettings
that adds the full TypeName to the serialization as it was happening by default https://www.newtonsoft.com/json/help/html/serializetypenamehandling.htmFollowed the configuration suggested in https://github.com/dotnet/docs/issues/33943
And everything works fine. No assembly nor namespace added to de serialized JSON.
Thanks for the help again!