You cannot save a class that does not contain a property that represents the item ID
See original GitHub issueI 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)
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:
- Created 9 years ago
- Comments:27 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just wanted to share my experience with this error. In my case, I was using a base interface that had the following properties:
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:
With the ID properly mapped, the error went away.
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