@Jetski5822 created:
https://orchard.codeplex.com/workitem/16043
Generating of the database works in orchard-43977 but fails in the latest build orchard-45838 - Heres what happens
If you change the Hack Session locator to point to a SQL Server database
private ISessionFactory BindSessionFactory() {
// TEMP: a real scenario would call for a session factory locator
// that would eventually imply the need for configuration against one or more actual sources
// and a means to enlist record types from active packages into correct session factory
var database = MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromAppSetting("database"));
//var hackPath = HostingEnvironment.MapPath("~/App_Data/hack.db");
//var database = SQLiteConfiguration.Standard.UsingFile(hackPath);
var recordTypes = _compositionStrategy.GetRecordTypes();
return _sessionFactory ??
Interlocked.CompareExchange(
ref _sessionFactory,
BuildSessionFactory(database, recordTypes), null) ?? _sessionFactory;
}
And run Orchard.... You recieve the below error. This problem did not occur in Release orchard-43977 but occurs in the latest build orchard-45838
Server Error in '/' Application.
The INSERT statement conflicted with the FOREIGN KEY constraint "FK7D663EC52BE2D2B1". The conflict occurred in database "Orchard", table "dbo.CommonRecord", column 'Id'.
The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK7D663EC52BE2D2B1". The conflict occurred in database "Orchard", table "dbo.CommonRecord", column 'Id'.
The statement has been terminated.
Source Error:
Line 110: public virtual void Create(T entity) {
Line 111: Logger.Debug("Create {0}", entity);
Line 112: Session.Save(entity);
Line 113: }
Line 114:
Source File: D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard\Data\Repository.cs Line: 112
Stack Trace:
[SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK7D663EC52BE2D2B1". The conflict occurred in database "Orchard", table "dbo.CommonRecord", column 'Id'.
The statement has been terminated.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2394
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +83
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() +12
NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) +306
NHibernate.Id.InsertSelectDelegate.ExecuteAndExtract(IDbCommand insert, ISessionImplementor session) +83
NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder) +113
[GenericADOException: could not insert: [Orchard.ContentManagement.Records.ContentItemRecord][SQL: INSERT INTO ContentItemRecord VALUES (?); select SCOPE_IDENTITY()]]
NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder) +290
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session) +266
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Object obj, ISessionImplementor session) +358
NHibernate.Action.EntityIdentityInsertAction.Execute() +260
NHibernate.Engine.ActionQueue.Execute(IExecutable executable) +187
NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate(Object entity, EntityKey key, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) +780
NHibernate.Event.Default.AbstractSaveEventListener.PerformSave(Object entity, Object id, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) +539
NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) +254
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) +98
NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) +56
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event) +199
NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event) +153
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event) +325
NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event) +204
NHibernate.Impl.SessionImpl.Save(Object obj) +165
Orchard.Data.Repository1.Create(T entity) in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard\Data\Repository.cs:112 Orchard.Data.Repository
1.Orchard.Data.IRepository.Create(T entity) in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard\Data\Repository.cs:36
Orchard.ContentManagement.DefaultContentManager.Create(ContentItem contentItem, VersionOptions options) in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard\ContentManagement\DefaultContentManager.cs:304
Orchard.ContentManagement.DefaultContentManager.Create(ContentItem contentItem) in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard\ContentManagement\DefaultContentManager.cs:278
Orchard.ContentManagement.ContentCreateExtensions.Create(IContentManager manager, String contentType, Action1 initialize) in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard\ContentManagement\ContentExtensions.cs:39 Orchard.Core.Settings.Services.SiteService.GetSiteSettings() in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard.Web\Core\Settings\Services\SiteService.cs:30 Orchard.Mvc.Filters.AdminFilter.OnActionExecuting(ActionExecutingContext filterContext) in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard\Mvc\Filters\AdminFilter.cs:21 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +47
System.Web.Mvc.<>c__DisplayClassf.b__c() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +254 System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +254
System.Web.Mvc.<>c__DisplayClassf.b__c() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +192
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314
System.Web.Mvc.Controller.ExecuteCore() +105
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +58
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) +61
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext) +111
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext httpContext) +40
System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +7
Orchard.Web._Default.Page_Load(Object sender, EventArgs e) in D:\InformationServices\Prototypes\CMS\orchard-45731\trunk\src\Orchard.Web\Default.aspx.cs:16
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927