-
-
Notifications
You must be signed in to change notification settings - Fork 122
Closed
Description
I get the following error because I have an entity called "Set" (like a music set) in my model.
StartIndex cannot be less than zero. Parameter name: startIndex at System.String.Remove(Int32 startIndex, Int32 count) at SQLite.CodeFirst.Utility.SqliteAssociationType.IsSelfReferencing(AssociationType associationType) at SQLite.CodeFirst.Utility.SqliteAssociationType..ctor(AssociationType associationType, EntityContainer container) ...
This code throws the exception. I would check the ToRole.Name length first. If less than 4, return false;
private const string SelfReferencingPostfix = "Self";
private static bool IsSelfReferencing(AssociationType associationType)
{
return associationType.Constraint.ToRole.Name.Remove(associationType.Constraint.ToRole.Name.Length - SelfReferencingPostfix.Length, SelfReferencingPostfix.Length) == associationType.Constraint.FromRole.Name;
}
Maybe change to:
private static bool IsSelfReferencing(AssociationType associationType)
{
var toRoleName = associationType.Constraint.ToRole.Name;
if (toRoleName.Length < 4)
return false;
return toRoleName.Remove(toRoleName.Length - SelfReferencingPostfix.Length, SelfReferencingPostfix.Length) == associationType.Constraint.FromRole.Name;
}
Metadata
Metadata
Assignees
Labels
No labels