Re: Changing Property Types

45 views
Skip to first unread message

Oren Eini

unread,
Nov 16, 2012, 12:11:38 PM11/16/12
to ravendb
You should be able to just do the change. And every time that you
load / save a Part, it will update the value from int to string.
There shouldn't be anything else that you need to do.

On Nov 16, 7:07 pm, EisenbergEffect <r...@bluespireconsulting.com>
wrote:
> I have some data in production that is being stored as an int. I need to
> change the property type to a string. Is there any problem in doing this?
> Can I just change it on my class and have it work when I deploy? Or is
> there a more manual migration step that has to happen? Here's a concrete
> example of the before and after I need to manage:
>
> Before:
>
>         public class Part {
>             public int Value { get; set; }
>             public int? Sides { get; set; }
>             public string Tag { get; set; }
>         }
>
> After:
>
>         public class Part {
>             public int Value { get; set; }
>             public string Sides { get; set; }
>             public string Tag { get; set; }
>         }

EisenbergEffect

unread,
Nov 16, 2012, 12:17:39 PM11/16/12
to rav...@googlegroups.com
That's what I thought....but I wanted to be sure. Awesome. Really wonderful.

Jeremy Holt

unread,
Nov 16, 2012, 7:30:23 PM11/16/12
to rav...@googlegroups.com
I do this all the time. If the database isn't too large, I simply write a loop that just loads and stores the document again. Boy is this faster than developing in SQL :)

var query= session.Query<Contracts>().ToList();
foreach(var contract in contracts)
{
session.Store(contract)
}
session.SaveChanges()

Chris Marisic

unread,
Nov 19, 2012, 9:56:38 AM11/19/12
to rav...@googlegroups.com
For future readers, remember that RavenDB is not a stupid orm and is safe by default.  session.Query<Contracts>().ToList(); will not pull your entire database into memory the way an ORM will, and that you need to handle batching properly. http://ravendb.net/docs/intro/safe-by-default
Reply all
Reply to author
Forward
0 new messages