Development

Fixing an AmbiguousMatchException in Optimizely CMS 12

By Ginbok3 min read

The Problem

You start your Optimizely CMS 12 application and get this error:

System.Reflection.AmbiguousMatchException:
Ambiguous match found for property 'Category'

Your application won't start. The CMS can't load content types.


Why It Happens

You have two properties with the same name in your content type.

This usually happens when:

Example of the problem:

// Base class (in Optimizely)
public class ContentData
{
    public virtual ContentReference Category { get; set; }
}

// Your class
public class ArticlePage : PageData
{
    // ❌ ERROR: This creates a duplicate!
    public virtual ContentReference Category { get; set; }
}

The Solution

Simply rename your property to something unique.

That's it. No SQL. No database cleanup. Just rename the property.

Before (Broken):

public class ArticlePage : PageData
{
    [Display(Name = "Category")]
    public virtual ContentReference Category { get; set; }  // ❌ Duplicate!
}

After (Fixed):

public class ArticlePage : PageData
{
    [Display(Name = "Category")]
    public virtual ContentReference ArticleCategory { get; set; }  // ✅ Unique name
}

That's all you need to do.


Step-by-Step Fix

  1. Find the error in your logs to see which property is duplicated
  2. Locate the content type causing the issue
  3. Rename the property to something unique
  4. Restart your application

Done.


Common Mistakes

Mistake 1: Using new Keyword

// ❌ DON'T DO THIS
public class ArticlePage : PageData
{
    public new ContentReference Category { get; set; }
}

The compiler allows it, but Optimizely's reflection engine doesn't.

Mistake 2: Shadowing Base Properties

// If base class has "Category"
public class MyPage : BasePage
{
    // ❌ DON'T duplicate the name
    public virtual ContentReference Category { get; set; }
}

Solution: Always check your base class for existing property names.


How to Prevent This

  1. Use unique property names in your content types
  2. Check base classes before adding new properties
  3. Never use the new keyword on CMS properties
  4. Use prefixes if needed (e.g., ArticleCategory instead of Category)

Common Questions

Q: Will I lose my content data?

A: No. When you rename a property, Optimizely creates a new property definition. Old data stays in the database but won't be displayed until you migrate it.

Q: Do I need to run SQL scripts?

A: No. Just rename the property in your code. Optimizely handles the rest.

Q: What about existing content?

A: Existing content will show empty values for the renamed property. You may need to re-enter data or create a migration script if you have a lot of content.


Real Example

I had an ArticlePage with a Category property. Turns out PageData or one of my base classes already had a Category property.

My fix:

// Changed from:
public virtual ContentReference Category { get; set; }

// To:
public virtual ContentReference ArticleCategory { get; set; }

Application started immediately after rebuild.


Summary

Problem: AmbiguousMatchException error
Cause: Duplicate property name
Solution: Rename the property to something unique
Time to fix: 2 minutes

That's it. No complicated database work needed.

#Optimizely#OptimizelyCMS12#CSharp#DotNet#AmbiguousMatchException#CMSDevelopment#SoftwareTroubleshooting#WebDevelopment
← Back to Articles
Fix AmbiguousMatchException in Optimizely CMS 12 | Schema Guide - Ginbok