2

I'm building my first N2 site, mostly by copying bits and pieces from the N2 Dinamico site and the MVC example site. I'm adding two properties to my ContentPage class:

    [EditableText]
    [Persistable(Length = 1024)] // to minimize select+1
    public virtual string Summary { get; set; }

    [EditableMediaUpload]
    [Persistable(Length = 256)] // to minimize select+1
    public virtual string Icon { get; set; }

The Persistable attribute will store the new field in its own column, rather than as a name/value pair that page properties typically use. The Intellisense hint on that attribute says "Adding this attribute to an existing system requires the database to be updated." And that sounds true, because when I try to launch the site I get a message that the Summary column name is invalid.

How do I update the database schema to add the Summary column? I can delete the whole database and let N2 recreate it, but that will get annoying once there's some real data in it. I can't see how to make N2 update the schema for me.

Carl Raymond
  • 4,429
  • 2
  • 25
  • 39

1 Answers1

3

Try opening http://site.com/n2/installation/Upgrade.aspx There is an option to update tables.

Dejan Milicic
  • 819
  • 9
  • 18
  • I just tried adding a new property with the [Persistable] attribute to my page class, and launched the site. I landed at the same installation page as when creating a new site. After setting in Web.config and logging in, I got the same error as above (naming the new column, of course). – Carl Raymond Aug 25 '11 at 20:12
  • I think this could be similar to your problem http://n2cms.codeplex.com/discussions/268830 – Dejan Milicic Aug 25 '11 at 20:21
  • I think that's it! Now I have to wait for the NuGet package to get updated. – Carl Raymond Aug 25 '11 at 21:10
  • Yes, but you can also create one yourself. Pull source code from github, run build/nugetdeploy.bat and use produced nupkg to see if it helps. If you have problems, you can contact me on email. – Dejan Milicic Aug 25 '11 at 21:27
  • I was doing this last week, before they published the packages in the NuGet repository. I just created fresh packages from source, and this fixed the problem, as well as one with Lucene. – Carl Raymond Aug 25 '11 at 23:54