question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

You cannot save a class that does not contain a property that represents the item ID

See original GitHub issue

@mikeedwards83

I am getting the following error periodically in Page Editor. Using TDS codegen with the template shown below. In can see that IPromoProxy implements IGlassBase in the codegen file. An IIS reset fixes this for a short period, then it returns. SC 7.2 Update-3 (Glass.Mapper.Sc v3.2.3.49)

See also: http://stackoverflow.com/questions/27574397/sitecore-pageeditor-randomly-shows-error-with-glass-mapper

You cannot save a class that does not contain a property that represents the item ID. Ensure that at least one property has been marked to contain the Sitecore ID. Type: Castle.Proxies.IPromoProxy

 at Glass.Mapper.Sc.Configuration.SitecoreTypeConfiguration.ResolveItem(Object target, Database database)
 at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression`1 field, Expression`1 standardOutput, T model, Object parameters, Context context, Database database, TextWriter writer)

Here is the template

public partial interface IGlassBase{

    [SitecoreId]
    Guid Id{ get; }

    [SitecoreInfo(SitecoreInfoType.Language)]
    Language Language{ get; }

    [SitecoreInfo(SitecoreInfoType.Version)]
    int Version { get; }

    [SitecoreInfo(SitecoreInfoType.Url)]
    string Url { get; }
}

public abstract partial class GlassBase : IGlassBase{

    [SitecoreId]
    public virtual Guid Id{ get; private set;}

    [SitecoreInfo(SitecoreInfoType.Language)]
    public virtual Language Language{ get; private set; }

    [SitecoreInfo(SitecoreInfoType.Version)]
    public virtual int Version { get; private set; }

    [SitecoreInfo(SitecoreInfoType.Url)]
    public virtual string Url { get; private set; }
}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:27 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
zbecknellcommented, Apr 4, 2018

Just wanted to share my experience with this error. In my case, I was using a base interface that had the following properties:

ID Id { get; set; }

Language Language { get; set; }

string Name { get; set; }

ID TemplateId { get; set; }

IEnumerable<ID> BaseTemplateIds { get; set; }

Item Item { get; set; }

I was relying mostly on auto-mapping throughout the project, but in a special case I needed to infer types. For a while it all worked fine, but then I started getting the error. My solution, which seems obvious now, was to be more explicit specifying my ID field with an attribute, like so:

[SitecoreId]
ID Id { get; set; }

With the ID properly mapped, the error went away.

0reactions
MinyieDiazcommented, Mar 28, 2018

I am also getting the same issue periodically. An app pool recycle seems to fix it for a while. Going to try using concrete classes like some users here suggested.

Using GlassMapper 3.2.3.50

Read more comments on GitHub >

github_iconTop Results From Across the Web

Glassmapper | Cannot save a class that does not contain a ...
1 Answer. You want to change your ID property to type Guid . Also, you can add the attribute SitecoreId to the property....
Read more >
"You cannot save a class that does not contain a property ...
"You cannot save a class that does not contain a property that represents the item ID" when GlassCast(ing) a branch template item, why?...
Read more >
Sitecore Glass Mapper Experience Editor Error with ...
Failed item resolve - You cannot save a class that does not contain a property that represents the item ID. Ensure that at...
Read more >
- Getting an error occurred when using experience editor in ...
Type, Boolean, Boolean)'. ERROR Failed item resolve - You cannot save a class that does not contain a property that represents the item...
Read more >
Error realted to Item Id while working with Glass Mapper in ...
GlassMapper: You can not save a class that does not contain a property that represents the item ID. Ensure that at least one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found