November Happy Hour will be moved to Thursday December 5th.

Can't create new properties on upgraded project.

Vote:
 

We've just released an upgraded CMS 12 site and started working with new features but now I realize that we cannot create new properties (code first) because "/EPiServer/cms/Stores/contentdata/16194_98172" crashes (stack trace added bellow).

I've removed everything non-vital from startup.cs just to make sure that there's no interferrence with other plugins but the problem still persist.

However, if I also add this property on the page type via admin mode the property is added correctly and it's marked as from code: "yes"

System.NullReferenceException: Object reference not set to an instance of an object.
   at Client.Web.Models.Pages.IframePage_DynamicProxy.get_LinkABC()
   at lambda_method407(Closure , Object , Object[] )
   at EPiServer.Validation.DataAnnotationsValidator`1.ValidateInstance(Object instance, List`1 validationResult, ValidationContext validationContext)
   at EPiServer.Validation.DataAnnotationsValidator`1.Validate(T instance)
   at EPiServer.Validation.Internal.ContextValidatorWrapper`2.Validate(Object instance)
   at EPiServer.Validation.Internal.ValidationService.ValidateRecursively(Object instance, Object context, HashSet`1 visitedInstances)
   at EPiServer.Validation.Internal.ValidationService.Validate(Object instance)
   at EPiServer.Cms.Shell.UI.Rest.Internal.ContentDataStore.<>c__DisplayClass20_1.<Validate>b__1(IValidationService x)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at EPiServer.Cms.Shell.UI.Rest.Internal.ContentDataStore.<>c__DisplayClass20_0.<Validate>b__0(IContent content)
   at EPiServer.Cms.Shell.UI.Rest.Internal.RestStatusUtil.ExecuteWithSecurityCheck[T](ContentReference contentLink, IContentLoader contentLoader, AccessLevel accessLevel, Func`2 func)
   at EPiServer.Cms.Shell.UI.Rest.Internal.ContentDataStore.Validate(ContentReference id, ValidationFilering filter)
   at lambda_method404(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
#308332
Edited, Sep 11, 2023 10:48
Vote:
 

Probably a de javu, but can you post the code for LinkABC?

Does the stacktrace point to same property all the times, or is it different every time?

#308338
Sep 11, 2023 13:06
Vote:
 

Hi Quan

It's a simple string property. It's always the same property (ie, the new one) so if I try to change property name or type it breaks.

[Display(
            Name = "Länk",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 10)]
        public virtual string LinkABC { get; set; }
#308339
Sep 11, 2023 13:08
Vote:
 

I'm out of idea. You are very welcome to get in touch with developer support service, so they can have a copy of your site and reproduce the issue. I'd be happy to take a look when that is in our hands

#308343
Sep 11, 2023 14:14
Vote:
 

I've just upgraded to CMS 12.22.6 and now the call to "/EPiServer/cms/Stores/contentdata/[ID]" returns 200 with an json-object but the new properties aren't found in the json response.

I wonder, can you disable/enable automatic creation of code first properties? If something went wrong with the db-upgrade and that setting is turned off somehow?

#308541
Sep 15, 2023 10:41
Vote:
 

You can learn about synchronization and how to disable here

#308545
Sep 15, 2023 16:32
Vote:
 

Hi Marks.

Thanks for the link. I have to test out "Episerver Developer Tools" and see if I can sort out what's wrong.

I noticed that I can create new content types and add/remove properties without a problem, so it must be something weird with the ones that has been migrated.

#308694
Sep 19, 2023 6:54
Vote:
 

So I've been playing around with ContentTypeModelRepository and I can see that my property is actually added to the page types PropertyDefinitionsModels but it's missing ExistingPropertyDefinitions (compared to a XhtmlString-property that was there before the upgrade).

The "BlaBla"-property is a simple int property:

[Display(Order = -1)]
public virtual int BlaBla { get; set; }

I tried to set a value programatically and got this error as well.

So if anyone have any clue I'm open for suggestions :)

#308703
Sep 19, 2023 11:55
Vote:
 

I saw in the logs that I have a bunch of these warnings:

EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister: Warning: Changes in the model were ignored because its version(0.0.0.0) is lower than version in the database(1.0).

I Googled it and stumbled upon this thread: https://world.optimizely.com/forum/developer-forum/cms-12/thread-container/2022/12/initialization-fails-after-upgrad-to-cms-12/

But I tried to add this setting to match with the db version but nothing happens.

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Version>1.0</Version>
    <AssemblyVersion>1.0</AssemblyVersion>
    <FileVersion>1.0</FileVersion>
  </PropertyGroup>

I also updated the Version-column in tblContentType to match the db version but still the same error. But I think I'm onto something here. Is there something I'm missing? 

#308750
Edited, Sep 20, 2023 7:26
Vote:
 

Maybe change the Assembly version to 2.0, just to see if it works?

#308755
Sep 20, 2023 9:00
Vote:
 

I does not I'm afraid. I've changed Version in tblContentType to 2.0.0.0 and AssemblyVersion to 2.0.0.0 but the error is still 

Changes in the model were ignored because its version(0.0.0.0) is lower than version in the database(1.0).

So i don't know where it gets 0.0.0.0 from.

#308758
Sep 20, 2023 9:22
Vote:
 

If you look into tblContentType, ModelType column, it should be something like this

Foundation.Features.Locations.Blocks.FilterActivitiesBlock, Foundation, Version=2021.4.1.0, Culture=neutral, PublicKeyToken=null

you can probably change it to see if has any effect

#308762
Sep 20, 2023 9:59
Vote:
 

Hmm, I tried to change it to 2.0.0.0 and got this error:

EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister: Warning: Changes in the model were ignored because its version(0.0.0.0) is lower than version in the database(2.0).

So I tried to change it to 0.0.0.0 and now it works!

So for anyone who has the same problem. My problem was that that in tblContentType my custom content types had this version

Client.Web.Models.Pages.LandingPage, Energiforetagen.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

But  changing it to 

Client.Web.Models.Pages.LandingPage, Energiforetagen.Web, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

solved the problem.

#308764
Sep 20, 2023 10:21
Vote:
 

Removing <AssemblyVersion> and <FileVersion> (if they exist) from csproj and adding <GenerateAssemblyInfo>true</GenerateAssemblyInfo> solved my problem.

#316439
Jan 31, 2024 8:58
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.