I get `Cannot insert the value NULL into column 'pkID', table 'tblPropertyDefinitionType'; ` when I export prod and use the database locally

Vote:
 

I've exported prod tons of times and never had this issue. I exported prod, imported the dacpac into SSMS, then copied the database to my app_data folder. I get this error in the event viewer:

Cannot insert the value NULL into column 'pkID', table 'tblPropertyDefinitionType'; column does not allow nulls.

Any ideas what's going on?

Full log:

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 2023-11-08 12:51:40 PM 
Event time (UTC): 2023-11-08 6:51:40 PM 
Event ID: d0565880785d4f9ea22c89402389cf99 
Event sequence: 1 
Event occurrence: 1 
Event detail code: 0 
 
Application information: 
    Application domain: /LM/W3SVC/2/ROOT-2-133439430853664478 
    Trust level: Full 
    Application Virtual Path: / 
 
Process information: 
    Process ID: 40352 
    Process name: iisexpress.exe 
 
Exception information: 
    Exception type: TargetInvocationException 
    Exception message: Exception has been thrown by the target of an invocation.
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args)
   at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
   at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

Initialize action failed for Initialize on class EPiServer.Initialization.Internal.PlugInInitialization, EPiServer, Version=11.20.3.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()
   at EPiServer.Framework.Initialization.InitializationEngine.ExecuteTransition(Boolean continueTransitions)
   at EPiServer.Framework.Initialization.InitializationModule.EngineExecute(HostType hostType, Action`1 engineAction)
   at EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType)
   at EPiServer.Global..ctor()
   at ClubCorp.Global..ctor()
   at ASP.global_asax..ctor() in c:\Users\\AppData\Local\Temp\Temporary ASP.NET Files\vs\4367862e\189850b1\App_global.asax._sn0ks2c.0.cs:line 0

Exception has been thrown by the target of an invocation.
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at EPiServer.PlugIn.Internal.PlugInRuntime.Call(TypesWithState typeWithState, String methodName)
   at EPiServer.PlugIn.Internal.PlugInRuntime.Call(String methodName)
   at EPiServer.PlugIn.Internal.PlugInRuntime.Start(Boolean reset)
   at EPiServer.Initialization.Internal.PlugInInitialization.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

Cannot insert the value NULL into column 'pkID', table 'club01mstr89mvrprod.cms.sqldb.20231108180006.dbo.tblPropertyDefinitionType'; column does not allow nulls. INSERT fails.
   at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
   at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
   at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
   at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
   at EPiServer.DataAccess.Internal.PropertyDefinitionTypeDB.<>c__DisplayClass5_0.<SaveToDB>b__0()
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass33_0`1.<ExecuteTransaction>b__0()
   at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
   at EPiServer.DataAccess.Internal.PropertyDefinitionTypeDB.Save(PropertyDefinitionType propertyDefinitionType)
   at EPiServer.DataAbstraction.Internal.PropertyDefinitionTypeRepository.Save(PropertyDefinitionType propertyDefinitionType)
   at EPiServer.PlugIn.PropertyDefinitionTypePlugInAttribute.RegisterPropertyDefinitions(PlugInDescriptor[] plugins, IPropertyDefinitionTypeRepository propertyDefinitionTypeRepository, IContentTypeRepository contentTypeRepository, IContentTypeModelAssigner contentModelAssigner)

 
 
Request information: 
    Request URL: https://localhost:44300/episerver/login 
    Request path: /episerver/login 
    User host address: ::1 
    User:  
    Is authenticated: False 
    Authentication Type:  
 
Thread information: 
    Thread ID: 5 
    Is impersonating: False 
    Stack trace:    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args)
   at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
   at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
 
 
Custom event details: 

#312189
Edited, Nov 08, 2023 18:58
Vote:
 

Can you see anything in your log? a full stacktrace might be helpful 

#312314
Nov 10, 2023 14:39
eperezjr - Nov 10, 2023 14:47
I attached the full log to the post.
Vote:
 

This looks like a CMS11 Solution, if you disable automatic schema updates in the web.config does your site load ? 

Something in your local content type models or a plugin trying to create content types or properties is causing the issue, disabling the schema updates can prove this theory 

<episerver.framework updateDatabaseSchema="false" createDatabaseSchema="false">

 

#312317
Nov 10, 2023 16:41
eperezjr - Nov 10, 2023 16:47
I added these properties to the episerver.framework node, but the same error occurs.
Vote:
 

Could also be schema migrations, search your code for classes that inherit MigrationStep and see if you find anything suspicious.

#312468
Nov 13, 2023 17:16
eperezjr - Nov 13, 2023 17:22
I do not see any references to MigrationStep in the code.
Vote:
 

Do you use the same codebase as on your prod to run this database? In particular, classes for property types? Maybe you changed namespaces / moved some classes around?

Based on exception, it fails trying save property definition type (classes marked with PropertyDefinitionTypePlugIn attribute). You can try examining table tblPropertyDefinitionType, maybe you will find something obviously wrong there.

#312518
Nov 14, 2023 7:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.