添加 Persistable 属性后如何更新 N2 中的数据库架构
我正在构建我的第一个 N2 站点,主要是通过复制 N2 Dinamico 站点和 MVC 示例站点的零碎内容。我向我的 ContentPage
类添加两个属性:
[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; }
Persistable
属性将新字段存储在其自己的列中,而不是页面属性通常存储的名称/值对使用。该属性的智能感知提示表示“将此属性添加到现有系统需要更新数据库”。这听起来是真的,因为当我尝试启动该网站时,我收到一条消息,提示“摘要”列名称无效。
如何更新数据库架构以添加摘要列?我可以删除整个数据库并让 N2 重新创建它,但是一旦其中有一些真实数据,这就会变得很烦人。我不知道如何让 N2 为我更新架构。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试打开 http://site.com/n2/installation/Upgrade.aspx
有一个更新表的选项。
Try opening http://site.com/n2/installation/Upgrade.aspx
There is an option to update tables.