Note that there are some explanatory texts on larger screens.

plurals
  1. PORavenDB throws casting exception after models namespace change
    primarykey
    data
    text
    <p>In the database, I have already stored hundreds of documents. Now the system architecture has changed and (among others) models was migrated into different namespace (in different assembly).</p> <p>Below, metadata of sample document is shown:</p> <p><img src="https://i.stack.imgur.com/WGyjI.jpg" alt="enter image description here"></p> <p>and code I'm using to fetch such document:</p> <pre><code>var configuration = documentSession.Load&lt;One.Social.Core.Entities.Setting&gt;("Setting"); </code></pre> <p>which throws casting exception:</p> <pre><code>[InvalidCastException: Unable to cast object of type 'One.QA.Core.Entities.Setting' to type 'One.Social.Core.Entities.Setting'.] </code></pre> <p><strong>UPDATE:</strong> </p> <p>Similiar error but from NewtonsoftJson rises, while I have collection of specified type inside the dosument, which now changed.</p> <p>In database I have Question document, which contains a list of Answers:</p> <p><img src="https://i.stack.imgur.com/qjnqR.jpg" alt="enter image description here"></p> <p>In the code, the type looks like that:</p> <pre><code>namespace One.Social.Ask.Web.Models { public class Question { public string Content { get; set; } public IList&lt;One.Social.Ask.Web.Models.Answer&gt; Answers { get; set; } } } </code></pre> <p>Answers namespace changed. In addition, now it's derived from IList&lt;>, no ICollection&lt;>. I don't need the <code>$type</code> meta now, it should be:</p> <p><img src="https://i.stack.imgur.com/GVI8q.jpg" alt="enter image description here">. </p> <p>While it is a list now, an error rises because of the old <code>$type</code> information:</p> <pre><code>Newtonsoft.Json.JsonSerializationException: Error resolving type specified in JSON 'System.Collections.ObjectModel.Collection`1[[One.QA.Core.Entities.Answer, One.QA.Core]], mscorlib'. ---&gt; Newtonsoft.Json.JsonSerializationException: Could not find type 'System.Collections.ObjectModel.Collection`1[[One.QA.Core.Entities.Answer, One.QA.Core]]' in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. </code></pre> <p>What is the best way to migrate all documents to reflect current types names ? Is there any built in mechanism ?</p> <p>Btw: I'm using RavenDB - Build #960</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload