OrchardCRM - 来自Migrations.cs的许多错误

时间:2014-05-19 01:50:52

标签: database orchardcms database-migration

为我的项目创建Models后,我运行codegen datamigration命令来生成Migrations.cs文件。 (下面的代码)我之前已经执行了几次相同的例程,它工作得很好 - 意思是,我可以看到按预期创建的表和列。但这一次,我只收到很多错误,并且没有在数据库端创建任何内容。我花了很长时间试图解决这个问题,但似乎什么都没有用,感觉非常莫名其妙。

Migrations.cs

using System;
using System.Collections.Generic;
using System.Data;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace Aecom.iNSIPP.COA {
    public class Migrations : DataMigrationImpl {

    public int Create() {

        SchemaBuilder.CreateTable("CoaScenarioPartRecord", table => table
            .ContentPartRecord()
            .Column("ScenarioName", DbType.String)
            .Column("ScenarioLocation", DbType.String)
            .Column("ScenarioDescription", DbType.String)
            .Column("ScenarioPreferredFlag", DbType.Boolean)
            .Column("ScenarioDateModified", DbType.String)
            .Column("ScenarioCreator", DbType.String)
        );

        SchemaBuilder.CreateTable("CoaActionPartRecord", table => table
            .ContentPartRecord()
            .Column("ActionName", DbType.String)
            .Column("ActionDescription", DbType.String)
            .Column("ActionPlanContext", DbType.String)
            .Column("ActionLocation", DbType.String)
            .Column("ActionTheme", DbType.String)
            .Column("ActionType", DbType.String)
            .Column("ActionTimeframe", DbType.Int32)
            .Column("ActionRelatedDirective", DbType.Int32)
            .Column("ActionFacilityAffected", DbType.String)
            .Column("ActionAffectedArea", DbType.Int32)
            .Column("ActionAffectedAreaUnits", DbType.String)
            .Column("ActionMapReference", DbType.String)
            .Column("ActionCost", DbType.Int32)
        );

        SchemaBuilder.CreateTable("CoaIssuePartRecord", table => table
            .ContentPartRecord()
            .Column("IssueName", DbType.String)
            .Column("IssueDescription", DbType.String)
            .Column("IssuePlanContext", DbType.String)
            .Column("IssueSCA", DbType.String)
            .Column("IssueLocation", DbType.String)
            .Column("IssueDriver", DbType.String)
            .Column("IssueTheme", DbType.String)
            .Column("IssueImportance", DbType.Int32)
            .Column("IssueJustification", DbType.String)
            .Column("IssueReview1", DbType.String)
            .Column("IssueReview1Date", DbType.String)
            .Column("IssueReview1Comment", DbType.String)
            .Column("IssueReview2", DbType.String)
            .Column("IssueReview2Date", DbType.String)
            .Column("IssueReview2Comment", DbType.String)
        );

        SchemaBuilder.CreateTable("CoaActionIssueRecord", table => table
            .Column("Id", DbType.Int32, column => column.PrimaryKey().Identity())
            .Column("CoaActionPartRecord_id", DbType.Int32)
            .Column("CoaIssuePartRecord_id", DbType.Int32)
        );

        SchemaBuilder.CreateTable("CoaScenarioActionRecord", table => table
            .Column("Id", DbType.Int32, column => column.PrimaryKey().Identity())
            .Column("CoaScenarioPartRecord_id", DbType.Int32)
            .Column("CoaActionPartRecord_id", DbType.Int32)
        );

        ContentDefinitionManager.AlterPartDefinition("CoaScenarioPart", part => part.Attachable());
        ContentDefinitionManager.AlterPartDefinition("CoaActionPart", part => part.Attachable());

        return 1;
    }
}
}

我想特别提出的问题如下:

  • 可能会甩掉Migrations.cs并产生各种错误的罪魁祸首是什么?
  • 经验丰富/专家Orchard开发人员在遇到与Migrations.cs或Orchard数据库相关的错误时会做些什么?
  • 如果我真的陷入了困境,那么"适当的"让Migrations.cs重新设置的方法? (我还可以做什么,然后再次运行codegen或手动输入Migrations.cs)

错误日志中发现的一些错误(我只显示每个错误的前几行):

Orchard.Exceptions.DefaultExceptionPolicy - An unexpected exception was caught NHibernate.Exceptions.GenericADOException: could not execute query [ SELECT TOP (@p0) this_.Id as Id1216_2_, this_.Number as Number1216_2_, this_.Published as Published1216_2_, this_.Latest as Latest1216_2_, this_.Data as Data1216_2_, this_.ContentItemRecord_id as ContentI6_1216_2_, contentite1_.Id as Id1215_0_, contentite1_.Data ...

Orchard.Data.SessionLocator - Error while disposing the transaction. NHibernate.AssertionFailure: null id in Orchard.Indexing.Models.IndexingTaskRecord entry (don't flush the Session after an exception occurs) at NHibernate.Event.Default.DefaultFlushEntityEventListener.CheckId(Object obj, IEntityPersister persister, Object id, EntityMode entityMode) ...

Orchard.Exceptions.DefaultExceptionPolicy - An unexpected exception was caught NHibernate.AssertionFailure: null id in Orchard.Indexing.Models.IndexingTaskRecord entry (don't flush the Session after an exception occurs) at NHibernate.Event.Default.DefaultFlushEntityEventListener.CheckId(Object obj, IEntityPersister persister, Object id, EntityMode entityMode) ...

NHibernate.AssertionFailure - An AssertionFailure occurred - this may indicate a bug in NHibernate or in your custom types. NHibernate.AssertionFailure: null id in Orchard.Indexing.Models.IndexingTaskRecord entry (don't flush the Session after an exception occurs)

Orchard.Exceptions.DefaultExceptionPolicy - An unexpected exception was caught NHibernate.AssertionFailure: null id in Orchard.Indexing.Models.IndexingTaskRecord entry (don't flush the Session after an exception occurs) at NHibernate.Event.Default.DefaultFlushEntityEventListener.CheckId(Object obj, IEntityPersister persister, Object id, EntityMode entityMode) ...

NHibernate.AssertionFailure - An AssertionFailure occurred - this may indicate a bug in NHibernate or in your custom types. NHibernate.AssertionFailure: null id in Orchard.Indexing.Models.IndexingTaskRecord entry (don't flush the Session after an exception occurs) ...

Orchard.ContentManagement.DefaultContentManager - GenericADOException thrown from IContentHandler by Orchard.Indexing.Handlers.CreateIndexingTaskHandler NHibernate.Exceptions.GenericADOException: could not execute batch command.[SQL: SQL not available] ---> System.Data.SqlClient.SqlException: Invalid object name 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. Invalid object name 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. ...

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 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. Invalid object name 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

NHibernate.Event.Default.AbstractFlushingEventListener - Could not synchronize database state with session NHibernate.Exceptions.GenericADOException: could not execute batch command.[SQL: SQL not available] ---> System.Data.SqlClient.SqlException: Invalid object name 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. Invalid object name 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) ...

Orchard.Exceptions.DefaultExceptionPolicy - An unexpected exception was caught System.NotImplementedException: The method or operation is not implemented. at Aecom.iNSIPP.Assets.Tokens.AssetTokens.Evaluate(Object context) at Orchard.Events.DelegateHelper.<>c__DisplayClass2b`2.<BuildAction>b__2a(Object target, Object[] p) ...

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 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) ...

 NHibernate.Event.Default.AbstractFlushingEventListener - Could not synchronize database state with session NHibernate.Exceptions.GenericADOException: could not execute batch command.[SQL: SQL not available] ---> System.Data.SqlClient.SqlException: Invalid object name 'Aecom_iNSIPP_COA_CoaScenarioPartRecord'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) ...

Orchard.Exceptions.DefaultExceptionPolicy - An unexpected exception was caught System.NotImplementedException: The method or operation is not implemented. at Aecom.iNSIPP.Assets.Tokens.AssetTokens.Evaluate(Object context) at Orchard.Events.DelegateHelper.<>c__DisplayClass2b`2.<BuildAction>b__2a(Object target, Object[] p) at Orchard.Events.DefaultOrchardEventBus.TryInvokeMethod(IEventHandler eventHandler, Type interfaceType, String messageName, String interfaceName, String methodName, IDictionary`2 arguments, IEnumerable& returnValue) ...

编辑:(整个堆栈顶部有3个错误)

Orchard.Exceptions.DefaultExceptionPolicy - 捕获到意外的异常System.NotImplementedException:未实现方法或操作。    at Aecom.iNSIPP.Assets.Tokens.AssetTokens.Evaluate(Object context)    在Orchard.Events.DelegateHelper。&lt;&gt; c__DisplayClass2b 2.<BuildAction>b__2a(Object target, Object[] p) at Orchard.Events.DefaultOrchardEventBus.TryInvokeMethod(IEventHandler eventHandler, Type interfaceType, String messageName, String interfaceName, String methodName, IDictionary 2个参数,IEnumerable&amp;的returnValue)    在Orchard.Events.DefaultOrchardEventBus.TryInvoke(IEventHandler eventHandler,String messageName,String interfaceName,String methodName,IDictionary 2 arguments, IEnumerable& returnValue) at Orchard.Events.DefaultOrchardEventBus.TryNotifyHandler(IEventHandler eventHandler, String messageName, String interfaceName, String methodName, IDictionary 2 eventData,IEnumerable&amp; returnValue)


NHibernate.Event.Default.AbstractFlushingEventListener - 无法使用会话NHibernate.Exceptions.GenericADOException同步数据库状态:无法执行批处理命令。[SQL:SQL不可用] ---&gt; System.Data.SqlClient.SqlException:无效的对象名称&#39; Aecom_iNSIPP_COA_CoaScenarioPartRecord&#39;。    at System.Data.SqlClient.SqlConnection.OnError(SqlException异常,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, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource 1完成,Int32超时,Task&amp; task,Boolean asyncWrite)    在System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1完成,String methodName,Boolean sendToPipe,Int32 timeout,Boolean asyncWrite)    在System.Data.SqlClient.SqlCommand.ExecuteNonQuery()    在System.Data.SqlClient.SqlCommandSet.ExecuteNonQuery()    at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ AdoNet \ SqlClientBatchingBatcher.cs:第87行    ---内部异常堆栈跟踪结束---    at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ AdoNet \ SqlClientBatchingBatcher.cs:第98行    at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ AdoNet \ AbstractBatcher.cs:第413行    at NHibernate.AdoNet.AbstractBatcher.ExecuteBatch()在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ AdoNet \ AbstractBatcher.cs:第397行    at NHibernate.AdoNet.AbstractBatcher.PrepareBatchCommand(CommandType类型,SqlString sql,SqlType [] parameterTypes)在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ AdoNet \ AbstractBatcher.cs:第133行    at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id,Object [] fields,Boolean [] notNull,Int32 j,SqlCommandInfo sql,Object obj,ISessionImplementor session)in c:\ Users \ sebros \ Documents \ My Projects \ nhibernate -core \ src \ NHibernate \ Persister \ Entity \ AbstractEntityPersister.cs:第2626行    at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id,Object [] fields,Object obj,ISessionImplementor session)in c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Persister \ Entity \ AbstractEntityPersister.cs:第3060行    at NHibernate.Action.EntityInsertAction.Execute()在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Action \ EntityInsertAction.cs:第59行    at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Engine \ ActionQueue.cs:第136行    at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Engine \ ActionQueue.cs:第125行    在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Engine \ ActionQueue.cs中的NHibernate.Engine.ActionQueue.ExecuteActions():第170行    在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Event \ Default \ AbstractFlushingEventListener.cs:第241行的NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource会话)中


Orchard.ContentManagement.DefaultContentManager - Orchard.Autoroute.Handlers.AutoroutePartHandler从IContentHandler抛出的GenericADOException NHibernate.Exceptions.GenericADOException:无法执行批处理命令。[SQL:SQL不可用] ---&gt; System.Data.SqlClient.SqlException:无效的对象名称&#39; Aecom_iNSIPP_COA_CoaScenarioPartRecord&#39;。    at System.Data.SqlClient.SqlConnection.OnError(SqlException异常,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, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource 1完成,Int32超时,Task&amp; 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.SqlCommandSet.ExecuteNonQuery() at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\SqlClientBatchingBatcher.cs:line 87 --- End of inner exception stack trace --- at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\SqlClientBatchingBatcher.cs:line 98 at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\AbstractBatcher.cs:line 413 at NHibernate.AdoNet.AbstractBatcher.ExecuteBatch() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\AbstractBatcher.cs:line 397 at NHibernate.AdoNet.AbstractBatcher.PrepareBatchCommand(CommandType type, SqlString sql, SqlType[] parameterTypes) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\AbstractBatcher.cs:line 133 at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 2626 at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 3060 at NHibernate.Action.EntityInsertAction.Execute() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Action\EntityInsertAction.cs:line 59 at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Engine\ActionQueue.cs:line 136 at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Engine\ActionQueue.cs:line 125 at NHibernate.Engine.ActionQueue.ExecuteActions() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Engine\ActionQueue.cs:line 170 at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line 253 at NHibernate.Event.Default.DefaultAutoFlushEventListener.OnAutoFlush(AutoFlushEvent event) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\DefaultAutoFlushEventListener.cs:line 38 at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet 1 querySpaces)在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Impl \ SessionImpl.cs:line 1180    at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria,IList results)c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Impl \ SessionImpl.cs:line 1959    at NHibernate.Impl.CriteriaImpl.List(IList results)in c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Impl \ CriteriaImpl.cs:line 265    在c:\ Users \ sebros \ Documents \ My Projects \ nhibernate-core \ src \ NHibernate \ Impl \ CriteriaImpl.cs中的NHibernate.Impl.CriteriaImpl.ListT:第277行    在Orchard.ContentManagement.DefaultContentQuery.Slice(Int32 skip,Int32 count)    在Orchard.ContentManagement.DefaultContentQuery.ContentQuery 1.Orchard.ContentManagement.IContentQuery<T>.List() at Orchard.Autoroute.Handlers.AutoroutePartHandler.ProcessAlias(AutoroutePart part) at Orchard.Autoroute.Handlers.AutoroutePartHandler.CreateAlias(AutoroutePart part) at Orchard.Autoroute.Handlers.AutoroutePartHandler.<.ctor>b__0(UpdateContentContext ctx, AutoroutePart part) at Orchard.ContentManagement.Handlers.ContentHandler.InlineStorageFilter 1.Updated(UpdateContentContext context,TPart instance)    在Orchard.ContentManagement.Handlers.StorageFilterBase 1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Updated(UpdateContentContext context) at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Updated(UpdateContentContext context) at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass7f.<UpdateEditor>b__7e(IContentHandler handler) at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable 1个事件,Action`1 dispatch,ILogger logger)

0 个答案:

没有答案