Error: Invalid object name 'Orchard_Widgets_LayerPartRecord' with my recipe

Topics: Customizing Orchard, General
May 24, 2013 at 3:04 AM
I'm attempting to use this recipe (it's long, had to chop some, sorry!) and it give the error in the subject. "CV.Prototype" is my module, and when I remove that from the Feature section it cooks just fine. The problem being that I need the module enabled (thus running the migrations) before the data can be imported.

Ideas?

```
<!--Exported from Orchard--> <Orchard>
<Recipe>
<Name>CV Prototype</Name>
<Description></Description>
<Author>Ben Power</Author>
<WebSite>http://orchardproject.net</WebSite>
<Tags></Tags>
<Version>1.0</Version>
</Recipe>
<Feature enable="Orchard.Blogs,Orchard.Comments,Orchard.Tags,Orchard.Alias,Orchard.Autoroute,TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.ContentPicker,Orchard.PublishLater,Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting,Orchard.ContentTypes,Orchard.Scripting,Orchard.Scripting.Lightweight,PackagingServices,Orchard.Packaging,Orchard.Warmup,Orchard.Projections,Orchard.Fields,TheThemeMachine,CV.Prototype" />
<Metadata>
<Types>
  <Site DisplayName="Site" />
  <ContainerWidget Stereotype="Widget" DisplayName="Container Widget">
    <CommonPart />
    <WidgetPart />
    <ContainerWidgetPart />
  </ContainerWidget>
  <Page ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" TypeIndexing.Included="true" DisplayName="Page">
    <NavigationPart />
    <CommonPart DateEditorSettings.ShowDateEditor="true" />
    <PublishLaterPart />
    <TitlePart />
    <AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-page'}]" AutorouteSettings.DefaultPatternIndex="0" />
    <BodyPart />
    <TagsPart />
    <LocalizationPart />
  </Page>
  <MenuItem Description="Represents a simple custom link with a text and an url." Stereotype="MenuItem" DisplayName="Custom Link">
    <MenuPart />
    <IdentityPart />
    <CommonPart />
  </MenuItem>
  <Menu DisplayName="Menu">
    <CommonPart OwnerEditorSettings.ShowOwnerEditor="false" />
    <TitlePart />
  </Menu>
  <MenuWidget Stereotype="Widget" DisplayName="Menu Widget">
    <CommonPart />
    <IdentityPart />
    <WidgetPart />
    <MenuWidgetPart />
  </MenuWidget>
  <HtmlMenuItem Description="Renders some custom HTML in the menu." BodyPartSettings.FlavorDefault="html" Stereotype="MenuItem" DisplayName="Html Menu Item">
    <MenuPart />
    <BodyPart />
    <CommonPart />
    <IdentityPart />
  </HtmlMenuItem>
  <ContentMenuItem Description="Adds a Content Item to the menu." Stereotype="MenuItem" DisplayName="Content Menu Item">
    <MenuPart />
    <CommonPart />
    <IdentityPart />
    <ContentMenuItemPart />
  </ContentMenuItem>
  <User ContentTypeSettings.Creatable="False" DisplayName="User" />
  <Layer DisplayName="Layer">
    <LayerPart />
    <CommonPart OwnerEditorSettings.ShowOwnerEditor="false" />
  </Layer>
  <HtmlWidget Stereotype="Widget" DisplayName="Html Widget">
    <WidgetPart />
    <BodyPart />
    <CommonPart />
    <IdentityPart />
  </HtmlWidget>
  <Blog DisplayName="Blog">
    <BlogPart />
    <CommonPart />
    <TitlePart />
    <AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-blog'}]" AutorouteSettings.DefaultPatternIndex="0" />
    <MenuPart />
    <AdminMenuPart AdminMenuPartTypeSettings.DefaultPosition="2" />
    <CommentsContainerPart />
  </Blog>
  <BlogPost ContentTypeSettings.Draftable="True" TypeIndexing.Included="true" DisplayName="Blog Post">
    <BlogPostPart />
    <CommonPart DateEditorSettings.ShowDateEditor="true" />
    <PublishLaterPart />
    <TitlePart />
    <AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Blog and Title', Pattern: '{Content.Container.Path}/{Content.Slug}', Description: 'my-blog/my-post'}]" AutorouteSettings.DefaultPatternIndex="0" />
    <BodyPart />
    <CommentsPart />
    <TagsPart />
    <LocalizationPart />
  </BlogPost>
  <RecentBlogPosts Stereotype="Widget" DisplayName="Recent Blog Posts">
    <RecentBlogPostsPart />
    <CommonPart />
    <WidgetPart />
  </RecentBlogPosts>
  <BlogArchives Stereotype="Widget" DisplayName="Blog Archives">
    <BlogArchivesPart />
    <CommonPart />
    <WidgetPart />
  </BlogArchives>
  <Comment DisplayName="Comment">
    <CommentPart />
    <CommonPart />
    <IdentityPart />
  </Comment>
  <Query DisplayName="Query">
    <QueryPart />
    <TitlePart />
    <IdentityPart />
  </Query>
  <ProjectionWidget Stereotype="Widget" DisplayName="Projection Widget">
    <WidgetPart />
    <CommonPart />
    <IdentityPart />
    <ProjectionPart />
  </ProjectionWidget>
  <ProjectionPage ContentTypeSettings.Creatable="True" DisplayName="Projection">
    <CommonPart />
    <TitlePart />
    <AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-projections'}]" AutorouteSettings.DefaultPatternIndex="0" />
    <MenuPart />
    <ProjectionPart />
    <AdminMenuPart AdminMenuPartTypeSettings.DefaultPosition="5" />
  </ProjectionPage>
  <NavigationQueryMenuItem Description="Injects menu items from a Query" Stereotype="MenuItem" DisplayName="Query Link">
    <NavigationQueryPart />
    <MenuPart />
    <CommonPart />
  </NavigationQueryMenuItem>
  <Category ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" DisplayName="Category">
    <CommonPart />
    <TitlePart />
    <AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Category Title', Pattern: 'category/{Content.Slug}', Description: 'category/category-title'}]" />
    <CategoryPart />
  </Category>
  <Product ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" DisplayName="Product">
    <CommonPart />
    <TitlePart />
    <AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Product Title', Pattern: 'product/{Content.Slug}', Description: 'product/product-title'}]" AutorouteSettings.DefaultPatternIndex="0" />
    <ProductPart />
  </Product>
</Types>
<Parts>
  <CommonPart ContentPartSettings.Attachable="True" />
  <WidgetPart ContentPartSettings.Attachable="True" />
  <ContainerWidgetPart />
  <NavigationPart ContentPartSettings.Attachable="True" />
  <PublishLaterPart ContentPartSettings.Attachable="True" />
  <TitlePart ContentPartSettings.Attachable="True" />
  <AutoroutePart ContentPartSettings.Attachable="True" />
  <BodyPart ContentPartSettings.Attachable="True" BodyPartSettings.FlavorDefault="html" />
  <TagsPart ContentPartSettings.Attachable="True" />
  <LocalizationPart />
  <MenuPart ContentPartSettings.Attachable="True" />
  <IdentityPart ContentPartSettings.Attachable="True" />
  <MenuWidgetPart />
  <ContentMenuItemPart />
  <LayerPart />
  <BlogPart />
  <AdminMenuPart ContentPartSettings.Attachable="True" />
  <CommentsContainerPart />
  <BlogPostPart />
  <CommentsPart ContentPartSettings.Attachable="True" />
  <RecentBlogPostsPart />
  <BlogArchivesPart />
  <CommentPart />
  <QueryPart />
  <ProjectionPart />
  <NavigationQueryPart />
  <CategoryPart />
  <ProductPart />
</Parts>
</Metadata>

<Settings />

<Migration features="*" />

snip
Developer
May 27, 2013 at 1:12 PM
Please attach the debugger and have it break on that exception. Following the stack trace up & down should provide more hints.
May 27, 2013 at 11:58 PM
Here is the stack trace from the error log. I only included the first three entries.
2013-05-28 08:48:43,606 [18] NHibernate.Util.ADOExceptionReporter - Invalid object name 'Orchard_Projections_FieldIndexPartRecord'.
2013-05-28 08:48:43,629 [18] Orchard.ContentManagement.DefaultContentManager - GenericADOException thrown from IContentHandler by Orchard.Autoroute.Handlers.AutoroutePartHandler
NHibernate.Exceptions.GenericADOException: could not execute batch command.[SQL: SQL not available] ---> System.Data.SqlClient.SqlException: Invalid object name 'Orchard_Projections_FieldIndexPartRecord'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Data.SqlClient.SqlCommand.ExecuteBatchRPCCommand()
   at System.Data.SqlClient.SqlCommandSet.ExecuteNonQuery()
   at NHibernate.AdoNet.SqlClientSqlCommandSet.ExecuteNonQuery()
   at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)
   --- End of inner exception stack trace ---
   at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)
   at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)
   at NHibernate.AdoNet.AbstractBatcher.ExecuteBatch()
   at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
   at NHibernate.Engine.ActionQueue.ExecuteInserts()
   at NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate(Object entity, EntityKey key, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
   at NHibernate.Event.Default.AbstractSaveEventListener.PerformSave(Object entity, Object id, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
   at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
   at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)
   at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
   at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
   at NHibernate.Impl.SessionImpl.Save(Object obj)
   at Orchard.Data.Repository`1.Create(T entity) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard\Data\Repository.cs:line 96
   at Orchard.Data.Repository`1.Orchard.Data.IRepository<T>.Create(T entity) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard\Data\Repository.cs:line 36
   at Orchard.Alias.Implementation.Storage.AliasStorage.Set(String path, IDictionary`2 routeValues, String source) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard.Web\Modules\Orchard.Alias\Implementation\Storage\AliasStorage.cs:line 67
   at Orchard.Alias.Implementation.DefaultAliasService.Set(String aliasPath, RouteValueDictionary routeValues, String aliasSource) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard.Web\Modules\Orchard.Alias\Implementation\DefaultAliasService.cs:line 31
   at Orchard.Alias.Implementation.DefaultAliasService.Replace(String aliasPath, RouteValueDictionary routeValues, String aliasSource) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard.Web\Modules\Orchard.Alias\Implementation\DefaultAliasService.cs:line 74
   at Orchard.Autoroute.Services.AutorouteService.PublishAlias(AutoroutePart part) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard.Web\Modules\Orchard.Autoroute\Services\AutorouteService.cs:line 72
   at Orchard.Autoroute.Handlers.AutoroutePartHandler.PublishAlias(AutoroutePart part) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard.Web\Modules\Orchard.Autoroute\Handlers\AutoroutePartHandler.cs:line 73
   at Orchard.Autoroute.Handlers.AutoroutePartHandler.<.ctor>b__2(PublishContentContext ctx, AutoroutePart part) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard.Web\Modules\Orchard.Autoroute\Handlers\AutoroutePartHandler.cs:line 38
   at Orchard.ContentManagement.Handlers.ContentHandler.InlineStorageFilter`1.Published(PublishContentContext context, TPart instance) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 156
   at Orchard.ContentManagement.Handlers.StorageFilterBase`1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Published(PublishContentContext context) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard\ContentManagement\Handlers\StorageFilterBase.cs:line 81
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Published(PublishContentContext context) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 274
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass3f.<Publish>b__3d(IContentHandler handler) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard\ContentManagement\DefaultContentManager.cs:line 357
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in c:\TFSRoot\CatalogueOrchardPrototype\src\Orchard\InvokeExtensions.cs:line 17
2013-05-28 08:48:43,722 [18] NHibernate.AdoNet.AbstractBatcher - Could not execute query: SELECT warmupsett0_.Id as Id345_0_, warmupsett0_.Urls as Urls345_0_, warmupsett0_.Scheduled as Scheduled345_0_, warmupsett0_.Delay as Delay345_0_, warmupsett0_.OnPublish as OnPublish345_0_ FROM Orchard_Warmup_WarmupSettingsPartRecord warmupsett0_ WHERE warmupsett0_.Id=@p0
System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'Orchard_Warmup_WarmupSettingsPartRecord'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
ClientConnectionId:992532ee-a63c-41e1-be3d-f78725b1d843
May 28, 2013 at 12:02 AM
Edited May 28, 2013 at 12:05 AM
From the debugger:
>   Orchard.Framework.dll!Orchard.Data.Repository<Orchard.ContentManagement.Records.ContentItemRecord>.Create(Orchard.ContentManagement.Records.ContentItemRecord entity) Line 96 + 0x1a bytes  C#
    Orchard.Framework.dll!Orchard.Data.Repository<Orchard.ContentManagement.Records.ContentItemRecord>.Orchard.Data.IRepository<T>.Create(Orchard.ContentManagement.Records.ContentItemRecord entity) Line 36 + 0xe bytes   C#
    Orchard.Framework.dll!Orchard.ContentManagement.DefaultContentManager.Create(Orchard.ContentManagement.ContentItem contentItem, Orchard.ContentManagement.VersionOptions options) Line 482 + 0x22 bytes C#
    Orchard.Framework.dll!Orchard.ContentManagement.ContentCreateExtensions.Create(Orchard.ContentManagement.IContentManager manager, Orchard.ContentManagement.IContent content) Line 25 + 0x29 bytes  C#
    App_Web_ngaehgnt.dll!CV.Prototype.Migrations.UpdateFrom1() Line 132 + 0xe bytes C#
    [External Code] 
    Orchard.Framework.dll!Orchard.Data.Migration.DataMigrationManager.Update(string feature) Line 105 + 0x47 bytes  C#
    Orchard.Framework.dll!Orchard.Data.Migration.DataMigrationCoordinator.Installing(Orchard.Environment.Extensions.Models.Feature feature) Line 26 + 0xf bytes C#
    [External Code] 
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.TryInvokeMethod(Orchard.Events.IEventHandler eventHandler, System.Type interfaceType, string methodName, System.Collections.Generic.IDictionary<string,object> arguments, out System.Collections.IEnumerable returnValue) Line 83 + 0x3b bytes  C#
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.TryInvoke(Orchard.Events.IEventHandler eventHandler, string interfaceName, string methodName, System.Collections.Generic.IDictionary<string,object> arguments, out System.Collections.IEnumerable returnValue) Line 68 + 0x14 bytes C#
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.TryNotifyHandler(Orchard.Events.IEventHandler eventHandler, string messageName, string interfaceName, string methodName, System.Collections.Generic.IDictionary<string,object> eventData, out System.Collections.IEnumerable returnValue) Line 52 + 0x14 bytes  C#
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.NotifyHandlers(string messageName, System.Collections.Generic.IDictionary<string,object> eventData) Line 40 + 0x4a bytes    C#
    [External Code] 
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.Notify(string messageName, System.Collections.Generic.IDictionary<string,object> eventData) Line 26 + 0x1e bytes    C#
    Orchard.Framework.dll!Orchard.Events.EventsInterceptor.Intercept(Castle.Core.Interceptor.IInvocation invocation) Line 26 + 0x38 bytes   C#
    [External Code] 
    Orchard.Framework.dll!Orchard.Environment.State.ShellStateCoordinator.Orchard.Environment.State.IShellStateManagerEventHandler.ApplyChanges() Line 178 + 0x2e bytes C#
    [External Code] 
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.TryInvokeMethod(Orchard.Events.IEventHandler eventHandler, System.Type interfaceType, string methodName, System.Collections.Generic.IDictionary<string,object> arguments, out System.Collections.IEnumerable returnValue) Line 83 + 0x3b bytes  C#
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.TryInvoke(Orchard.Events.IEventHandler eventHandler, string interfaceName, string methodName, System.Collections.Generic.IDictionary<string,object> arguments, out System.Collections.IEnumerable returnValue) Line 68 + 0x14 bytes C#
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.TryNotifyHandler(Orchard.Events.IEventHandler eventHandler, string messageName, string interfaceName, string methodName, System.Collections.Generic.IDictionary<string,object> eventData, out System.Collections.IEnumerable returnValue) Line 52 + 0x14 bytes  C#
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.NotifyHandlers(string messageName, System.Collections.Generic.IDictionary<string,object> eventData) Line 40 + 0x4a bytes    C#
    [External Code] 
    Orchard.Framework.dll!Orchard.Events.DefaultOrchardEventBus.Notify(string messageName, System.Collections.Generic.IDictionary<string,object> eventData) Line 26 + 0x1e bytes    C#
    Orchard.Framework.dll!Orchard.Environment.State.DefaultProcessingEngine.Execute(Orchard.Environment.State.DefaultProcessingEngine.Entry entry) Line 91 + 0x41 bytes C#
    Orchard.Framework.dll!Orchard.Environment.State.DefaultProcessingEngine.ExecuteNextTask() Line 67 + 0xb bytes   C#
    Orchard.Framework.dll!Orchard.Environment.DefaultOrchardHost.EndRequest() Line 223 + 0xc bytes  C#
    Orchard.Framework.dll!Orchard.Environment.DefaultOrchardHost.Orchard.Environment.IOrchardHost.EndRequest() Line 83 + 0xb bytes  C#
    Orchard.Web.dll!Orchard.Web.MvcApplication.HostEndRequest(System.Web.HttpApplication application, Orchard.Environment.IOrchardHost host) Line 42 + 0x9 bytes    C#
    Orchard.WarmupStarter.dll!Orchard.WarmupStarter.Starter<Orchard.Environment.IOrchardHost>.OnEndRequest(System.Web.HttpApplication application) Line 75 + 0x1d bytes C#
    Orchard.Web.dll!Orchard.Web.MvcApplication.Application_EndRequest() Line 33 + 0x10 bytes    C#
It breaks on 'Session.Save(entity);' in the Create method in Orchard\Data\Repository.cs.
Developer
May 30, 2013 at 12:51 PM
I've seen this before. Could you tell me more about your module, specifically what you're doing in your migration?
May 31, 2013 at 1:58 AM
The migration sets up a couple of ContentPartRecords, a non-content table to map a many to many relationship between them, and then creates some dummy data. Obviously I would like it to run the migration BEFORE the recipe import occurs, otherwise the types are not set up and the data is lost. Here is the migration stuff:
    public class Migrations : DataMigrationImpl {
        private readonly IRepository<ProductCategoryRecord> _productCategoryRepository;
        private readonly IContentManager _contentManager;

        public Migrations(IRepository<ProductCategoryRecord> productCategoryRepository, IContentManager contentManager) {
            _productCategoryRepository = productCategoryRepository;
            _contentManager = contentManager;
        }

        public int Create() {
            ContentDefinitionManager.AlterTypeDefinition("Category", builder => builder
                                                                                    .WithPart("CommonPart")
                                                                                    .WithPart("TitlePart")
                                                                                    .WithPart("AutoroutePart"));

            ContentDefinitionManager.AlterTypeDefinition("Category", builder => builder
                                                                                    .WithPart("AutoroutePart", partBuilder => partBuilder
                                                                                                                                  .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                                                                                                                                  .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                                                                                                                                  .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Category Title', Pattern: 'category/{Content.Slug}', Description: 'category/category-title'}]")));

            SchemaBuilder.CreateTable("CategoryPartRecord", table => table
                                                                         .ContentPartRecord()
                                                                         .Column<string>("Name")
                                                                         .Column<string>("Description")
                                                                         .Column<string>("Image")
                                                                         .Column<int>("CategoryProductRecord_Id")
                );

            ContentDefinitionManager.AlterTypeDefinition("Category", builder => builder
                                                                                    .WithPart("CategoryPart")
                                                                                    .Creatable()
                                                                                    .Draftable());


            ContentDefinitionManager.AlterTypeDefinition("Product", builder =>
                                                                    builder.WithPart("CommonPart")
                                                                           .WithPart("TitlePart")
                                                                           .WithPart("AutoroutePart"));

            ContentDefinitionManager.AlterTypeDefinition("Product", builder => builder
                                                                                   .WithPart("AutoroutePart", partBuilder => partBuilder
                                                                                                                                 .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                                                                                                                                 .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                                                                                                                                 .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Product Title', Pattern: 'product/{Content.Slug}', Description: 'product/product-title'}]")
                                                                                                                                 .WithSetting("AutorouteSettings.DefaultPatternIndex", "0")));

            SchemaBuilder.CreateTable("ProductPartRecord", table =>
                                                           table.ContentPartRecord()
                                                                .Column<string>("ProductCode")
                                                                .Column<string>("Description")
                                                                .Column<string>("Image")
                                                                .Column<string>("Notes")
                                                                .Column<decimal>("Price")
                                                                .Column<int>("CategoryProductRecord_Id")
                );

            ContentDefinitionManager.AlterTypeDefinition("Product", builder => builder
                                                                                   .WithPart("ProductPart")
                                                                                   .Creatable()
                                                                                   .Draftable());

            SchemaBuilder.CreateTable("ProductCategoryRecord", table =>
                                                               table
                                                                   .Column<int>("Id", col => col.PrimaryKey().Identity())
                                                                   .Column<int>("CategoryPartRecord_Id")
                                                                   .Column<int>("ProductPartRecord_Id"));


            ContentDefinitionManager.AlterPartDefinition("CategoryPart",
                                                         builder => builder.Attachable());

            ContentDefinitionManager.AlterPartDefinition("ProductPart",
                                                         builder => builder.Attachable()); 
            return 1;
        }

        public int UpdateFrom1() {

            var productPart = _contentManager.New("Product").As<ProductPart>();
            productPart.ProductCode = "Da Vinci code";
            productPart.ContentItem.As<TitlePart>().Title = productPart.ProductCode;
            productPart.Notes = "Da Vinci code notes";
            productPart.Image = "DC.jpg";
            productPart.Description = "Da Vinci code product";
            productPart.Price = (decimal)123.23;
            _contentManager.Create(productPart);
            _contentManager.Publish(productPart.ContentItem);

            productPart = _contentManager.New("Product").As<ProductPart>();
            productPart.ProductCode = "Halo";
            productPart.ContentItem.As<TitlePart>().Title = productPart.ProductCode;
            productPart.Notes = "Halo notes";
            productPart.Image = "Halo.jpg";
            productPart.Description = "Halo product";
            productPart.Price = (decimal)455.23;
            _contentManager.Create(productPart);
            _contentManager.Publish(productPart.ContentItem);

            var categoryPart = _contentManager.New("Category").As<CategoryPart>();
            categoryPart.Name = "Books";
            categoryPart.ContentItem.As<TitlePart>().Title = categoryPart.Name;
            categoryPart.Image = "Book.jpg";
            categoryPart.Description = "Book category";
            _contentManager.Create(categoryPart);
            _contentManager.Publish(categoryPart.ContentItem);

            categoryPart = _contentManager.New("Category").As<CategoryPart>();
            categoryPart.Name = "Games";
            categoryPart.ContentItem.As<TitlePart>().Title = categoryPart.Name;
            categoryPart.Image = "Games.jpg";
            categoryPart.Description = "Games category";
            _contentManager.Create(categoryPart);
            _contentManager.Publish(categoryPart.ContentItem);

            _productCategoryRepository.Create(new ProductCategoryRecord{ProductPartRecord=productPart.Record, CategoryPartRecord=categoryPart.Record} );


            return 2;
        }

    }
Thanks, and let me know if you need more!
Developer
May 31, 2013 at 1:07 PM
Ok, please try the following:
  1. In your module's manifest, add Orchard.Projections as a dependency to your feature(s) and retry your recipe.
  2. If that doesn't make a difference, instead of generating the data as part of the migration, put the data into your recipe in the <Data> element (which is probably better anyway). This requires you to implement the Importing/Exporting methods of your content part drivers if you are working with your own content part records.
Jun 12, 2013 at 2:34 AM
Adding Orchard.Projections did just the trick, thank you very much!

I agree the data generation should be done via the import/export module and that's how we will end up doing it. Cheers.