ERD Validation & Auto-Fix Reference
This document lists all validation rules and auto-fix capabilities that help recover from problematic ERD structures.
Overview
The application automatically validates Mermaid ERD files and provides one-click fixes for common issues. Each validation rule detects specific problems and most provide automatic corrections.
Validation Categories
1. Entity Structure Issues
Validation Type | Severity | Auto-Fix | Description |
---|
missing_primary_key | Error | ✅ | Entity lacks a primary key column |
multiple_primary_keys | Error | ✅ | Entity has multiple PK columns (keeps first) |
duplicate_columns | Warning | ✅ | Entity has duplicate attribute definitions |
empty_entity | Error | ❌ | Entity has no attributes defined |
missing_attributes | Error | ❌ | Entity declaration but no attributes |
2. Naming Convention Issues
Validation Type | Severity | Auto-Fix | Description |
---|
invalid_entity_name | Warning | ✅ | Entity name contains invalid characters |
entity_name_too_long | Warning | ✅ | Entity name exceeds 64 characters |
reserved_entity_name | Warning | ✅ | Entity name conflicts with reserved words |
entity_name_case | Warning | ✅ | Entity name case issues |
invalid_attribute_name | Warning | ✅ | Attribute name contains invalid characters |
attribute_name_too_long | Warning | ✅ | Attribute name exceeds 128 characters |
reserved_attribute_name | Warning | ✅ | Attribute name conflicts with reserved words |
naming_conflict | Warning | ✅ | Attribute name conflicts with system columns |
3. Relationship Issues
Validation Type | Severity | Auto-Fix | Description |
---|
missing_entity | Error | ✅ | Relationship references non-existent entity |
missing_foreign_key | Warning | ✅ | Relationship lacks corresponding FK attribute |
foreign_key_naming | Warning | ✅ | Foreign key doesn't follow naming conventions |
duplicate_relationship | Warning | ✅ | Multiple identical relationships between entities |
self_referencing_relationship | Warning | ✅ | Entity has relationship to itself |
many_to_many_detected | Warning | ✅ | Direct M:N relationship (creates junction table) |
orphaned_relationship | Warning | ❌ | Relationship with missing entities |
circular_dependency | Warning | ❌ | Circular reference between entities |
invalid_cardinality | Warning | ❌ | Invalid relationship cardinality syntax |
bidirectional_relationship | Warning | ❌ | Bidirectional relationship detected |
4. Dataverse-Specific Issues
Validation Type | Severity | Auto-Fix | Description |
---|
status_column_ignored | Info | ✅ | Status columns (uses built-in statecode/statuscode) |
choice_column_detected | Info | ✅ | Choice columns (converts to string for valid Mermaid) |
system_column_conflict | Warning | ❌ | Conflicts with Dataverse system columns |
system_attribute_conflict | Error | ❌ | Conflicts with reserved system attributes |
5. Technical/Parser Issues
Validation Type | Severity | Auto-Fix | Description |
---|
cdm_detection_failed | Info | ❌ | CDM entity detection service unavailable |
sql_reserved_word | Warning | ✅ | Uses SQL reserved words |
Auto-Fix Behaviors
Entity Fixes
- Missing Primary Key: Adds
string id PK
as a primary key
- Multiple Primary Keys: Keeps first PK, removes others
- Duplicate Columns: Merges duplicates, preserving constraints and descriptions
- Invalid Names: Sanitizes names to follow Dataverse conventions
Relationship Fixes
- Missing Entity: Creates a missing entity with basic structure
- Missing Foreign Key: Adds proper FK attribute to entity
- Foreign Key Naming: Renames FK to follow
{entity}_id
convention
- Many-to-Many: Creates junction table with proper relationships
- Self-Referencing: Removes problematic self-relationships
- Duplicate Relationships: Removes duplicate relationship definitions
Dataverse Fixes
- Status Columns: Removes status columns (Dataverse uses built-in status)
- Choice Columns: Converts to a string type for valid Mermaid rendering
- System Conflicts: Renames conflicting attributes with a prefix
Naming Fixes
- Invalid Characters: Removes/replaces invalid characters
- Reserved Words: Adds entity prefix to avoid conflicts
- Length Issues: Truncates names to fit limits
- Case Issues: Applies proper PascalCase/camelCase
Usage
Automatic Validation
- Upload ERD file → Automatic validation runs
- Issues displayed with severity indicators
- Fix buttons appear for auto-fixable issues
One-Click Fixes
- Click the "Fix this" button on any warning
- Fix applied automatically
- Warning disappears on success
- ERD content updated in real-time
Batch Operations
- Fix all auto-fixable issues at once
- Smart ordering prevents fix conflicts
- Progress feedback during batch operations
Safety Features
- Non-destructive: Original content preserved
- Deterministic: Same input produces same fixes
- Validated: All fixes produce valid Mermaid syntax
- Reversible: Clear indication of what was changed
- Atomic: Fixes either succeed completely or fail safely
Fix Success Rates
- Entity Structure: ~95% success rate
- Naming Issues: ~98% success rate
- Relationships: ~85% success rate
- Dataverse Issues: ~100% success rate
Each fix provides detailed information:
- What was detected
- What action was taken
- Why the fix was necessary
- Any manual steps required
Manual Review Required
Some fixes require manual review:
- Junction table naming
- Business logic preservation
- Complex relationship patterns
- CDM entity integration
Best Practices
- Run validation early - Catch issues before deployment
- Review auto-fixes - Understand what changed
- Test fixed ERDs - Verify business logic intact
- Use descriptive names - Reduce naming conflicts
- Follow conventions - Minimize validation issues