Hi @NARAWICH YOUBUA ,
"There was an error running the selected code generator: 'startIndex cannot be larger than length of string. (Parameter 'startIndex')' "
For this error, I checked some similar threads, that error comes from something like Substring, when the value passed into the startIndex param is greater than the total length of the string. For example, if you had a string like "Just Testing" and you did .Substring(12, 1), you'd get that exception, as the string is only 12 characters long (remember that the index is from 0, not 1, so the last index is 11).
I have created a new MVC application and refer the tutorial and test your code, the New Scaffloded Item function works well. The result like this:

You can refer the following steps to create a new MVC application and test.
- Create a new MVC application using the template, and select the Individual Accounts authentication type:

- In the Models or Data folder, add the User class, and add the DbSet in the ApplicationDbContext class:
public class ApplicationDbContext : IdentityDbContext { public DbSet<User> Users { get; set; } public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } } - In the Package Manager Console, use the following command to enable migration and generate the database:
Add-Migration InitialCreate Update-Database - In Solution Explorer, right-click the Controllers folder and select Add > New Scaffolded Item.
In the Add Scaffold dialog, select MVC Controller with views, using Entity Framework > Add.
Then, in the popup dialog, select the User class, ApplicationDbContext and click the Add button to add the controller and views. You could refer the document.
I use the above steps, and it works well on my side, you can check it.
If still not working, can you tell us your VS version, and can you create a simple sample to reproduce the problem and share it via github or Onedrive, then, we can help to check it.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion