Introduction

I have been messing with RavenDB over the past few days. Nothing serious, just getting a feel for it.

And I wanted to know what happens when I change my model, add properties and remove properties. I know I expected these two to just work but one always has to test it’s theories and not take things for granted.

For this I am no longer going to use the in memory server but the http one. Which you use like this.

vbnet Public Shared Function GetNewSession() As IDocumentSession _store = New DocumentStore With {.Url = "http://localhost:8080"} _store.Initialize() Return _store.OpenSession End Function and I have to start the server by running Raven.server.exe in the server folder of your RavenDB download.

Adding a property

I first add a plant to my database and then change the model to this.

vbnet Public Class Plant Public Property Id As String Public Property LatinName As String Public Property Familyname As String Public Property EnglishNames As ISet(Of String) Public Property FlowerColor As String Public Property PlantImage As Image End Class I have added a property called family name to the model and then I added another. I can now check my 2 new documents in RavenDB by going browsing to http://localhost:8080 you will need to have silverlight installed and remember that silverlight does not run on a 64x browser.

And here is the result. I just added 2 docs. One with family name and one without.

So I adapted the form I used in the previous post to see what happens when I load plants/1 and plants/1025. And here are the results.

It just works. No problem there.

Removing a property

So now I can just remove that property again. Add another plant and see if I can load them again.

I now have another plant with id 2049.

I can now show these docs in my form, I will just have to remove the family name property usage.

And that just works.

Conclusion

I can just change my schema/model without any trouble. I guess that is one of the good things about these document databases. If I was using an RDBMS I would have to not only change my model but also the schema of my database.