Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

String or binary data would be truncated. The statement has been terminated.



My InitializationEngine fails after I've rebuilt today giving me this error :  "String or binary data would be truncated. The statement has been terminated."

I know about the rule about max 50 characters, so I've checked my source control for any names more than 50 in last 2 days and I've found nothing bigger than 40.

I searched len of [ModelType] in table [tblContentType] in my DB but there was no problem in that either.

How can I trace the error?

More importantly, it was working fine last night so I don't know what could be the problem :(

[SqlException (0x80131904): String or binary data would be truncated.
The statement has been terminated.]
   System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +1697432
   System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +53
   System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) +2346
   System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping) +57
   System.Data.Common.DbDataAdapter.Update(DataTable dataTable) +207
   EPiServer.DataAccess.<>c__DisplayClass13.b__12() +3123
   EPiServer.Data.Providers.<>c__DisplayClass35`1.b__34() +194
   EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute(Func`1 method) +963
   EPiServer.DataAccess.PropertyDefinitionDB.Save(PropertyDefinition propertyDefinition) +396
   EPiServer.DataAbstraction.DefaultPropertyDefinitionRepository.Save(PropertyDefinition propertyDefinition, Boolean forceCacheClear) +240
   EPiServer.DataAbstraction.RuntimeModel.PropertyDefinitionSynchronizer.CreatePropertyDefinition(PropertyDefinitionModel model, Int32 contentTypeID) +479
   EPiServer.DataAbstraction.RuntimeModel.ContentTypeModelRegister.CommitProperties(Boolean deleteUnusedTypes) +458
   EPiServer.DataAbstraction.RuntimeModel.ContentTypeModelScanner.Sync(Boolean commitChanges) +320
   EPiServer.Initialization.ModelSyncInitialization.Initialize(InitializationEngine context) +456
   EPiServer.Framework.Initialization.ModuleNode.Execute(Action a, String key) +56
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +244

[InitializationException: Initialize action failed for Initialize on class EPiServer.Initialization.ModelSyncInitialization, EPiServer, Version=, Culture=neutral, PublicKeyToken=8fe83dea738b45b7]
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +750
   EPiServer.Framework.Initialization.InitializationEngine.Initialize(HostType hostType) +158
   EPiServer.Framework.Initialization.InitializationModule.Initialize(HostType hostType) +903
   EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +103
   EPiServer.Global..ctor() +108
   ASP.global_asax..ctor() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\e1da96e9\785ee6cf\App_global.asax.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +138
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +105
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1481
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +191
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +27
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +82
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +300
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712

Apr 27, 2016 11:59

The name length (max 100) should be catch by the API:s. How's about the EditCaption?

Edited, Apr 27, 2016 12:01
<p>Hi Quan,</p> <p>This is the max(len(x)) from my DB.</p> <p>tblContentType_modeltype: 222</p> <p>tblContentType_name:50</p> <p>tblPropertyDefinition_name:48</p> <p>tblPropertyDefinition_editcaption:17</p> <p></p> <p>I have another version of my db to use on another Patch and these values are the same for both, But the other one is working fine.</p>
Apr 27, 2016 12:14

Turn on log4net on full and see if that captures the failing contenttype and property. If it doesnt, turn on sql profiler or similar and check what values are the problem and then correct them...

Apr 27, 2016 12:36

Hi Daniel,

I could not find ant errors on profiler and also there was no other useful data on log file. :(

Apr 27, 2016 14:43

Thanks Quan, @Daniel, 

I restored my db from a back up from 2 days ago and now everything is working fine.  it seems that something messed up the DB. 

How to prevent it next time? :|

Apr 27, 2016 14:43

Without knowing what went wrong then it's hard to say. But you can compare the databases (the good and the faulty one) to see the differences - then perhaps we can find a way.


Apr 27, 2016 14:56

Hi Quan,

I've got the error again today.

Then,as you suggested, I've compared the running db with my backup from last night. It had some fields on MetaField (Ecommerce) table that belong to my other branch (with other connection string).

So in my opinion, it might happen if people switch their working branch, but dont rebuild their solutions before they browse the site. Is there any possible scenario?



Apr 28, 2016 11:05

Yes, it's of course a possible scenario. When you have some mismatches between your code and your database - anything can happen.

Apr 28, 2016 11:11

Thanks for your help ;)

Apr 28, 2016 13:29
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.