files

Code Snippets

Title: Orchard CMS Data Migration Event Example
Description: Simple Orchard CMS Data Migration Event define a content type in code
Category: Orchard
Visibility:  Public
Added by: castle on 8/28/2012

 This snippet currently has no votes. Why not log in and be the first to rate it?

Get link for this code snippet
Collapse code snippet
Expand code snippet
Tweet this snippet
Tweet about this snippet
Delete code snippet
Edit code snippet
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Core.Contents.Extensions;
using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;

namespace Orchard.Oak.Events
{
    public class Migration : DataMigrationImpl
    {

        public int create()
        {
            ContentDefinitionManager.AlterTypeDefinition("Event", cfg => cfg
                .Creatable()
                .WithPart("Event")
                .WithPart("TagsPart")
                .WithPart("RoutePart")
                .WithPart("CommonPart")
                .WithPart("MenuPart")
                .WithPart("PublishLaterPart")
                .WithPart("LocalizationPart")
                );


            ContentDefinitionManager.AlterPartDefinition("Event", cfg => cfg
                .WithField("Date", fcfg => fcfg.OfType("DateTimeField"))
                .WithField("Location", fcgf => fcgf.OfType("TextFeild")));

            return 1;
        }

       
    }
}