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.

startIndex cannot be larger than length of string. (Parameter 'startIndex')

See original GitHub issue

When there are existing custom migrations in my Migrations folder and I try to run the command Add-Migration in the package manager console I receive the following error:

startIndex cannot be larger than length of string. (Parameter 'startIndex')

Build started… Build succeeded. Microsoft.EntityFrameworkCore.Infrastructure[10403] Entity Framework Core 5.0.11 initialized ‘ApiDbContext’ using provider ‘Microsoft.EntityFrameworkCore.SqlServer’ with options: MigrationsAssembly=Infrastructure System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter ‘startIndex’) at System.String.Substring(Int32 startIndex, Int32 length) at System.String.Substring(Int32 startIndex) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsIdGenerator.GetName(String id) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsAssembly.<>c__DisplayClass13_0.<FindMigrationId>b__1(String id) at System.Linq.Enumerable.WhereEnumerableIterator 1.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable 1 source, Boolean& found) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable 1 source) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsAssembly.FindMigrationId(String nameOrId) at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) startIndex cannot be larger than length of string. (Parameter ‘startIndex’)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
a-gormancommented, Jul 20, 2022

I managed to reproduce this! I was running mismatched versions of Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.Design (specifically 7.0.0-preview.6.22329.4 and 6.0.7, respectively). I can’t say that the original poster had the exact same root cause, but if you run into the same problem, check your nuget packages!

0reactions
ajcvickerscommented, Dec 23, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

startIndex cannot be larger than length of string - ...
You're trying to take 35 characters after the 26th character (startIndex is zero-based), which is out of range. Second argument for SubString ...
Read more >
startIndex cannot be larger than length of string
So the error message you are receiving is due to the length of your string being incorrect for what you are trying to...
Read more >
startIndex cannot be larger than length of string. Parameter ...
Trying out my first test-service with a PowerShell action, trying to same the action I get an error "startIndex cannot be larger than...
Read more >
PRB: "Documents: startIndex cannot be larger than the ...
Symptom. When uploading a file or refreshing the factbox the error message "Documents: startIndex cannot be larger than the length of string.
Read more >
startIndex cannot be larger than length of string
startIndex cannot be larger than length of string. Parameter name: startIndex. Description: An unhandled exception occurred during the ...
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