efcore: System.ArgumentException: The string argument 'originalIdentifier' cannot be empty.

I am trying to scaffold an existing database using entity framework core, visual studio 2019, .net core 3.1

But I get the error “System.ArgumentException: The string argument ‘originalIdentifier’ cannot be empty.”

I can’t seem to point out what exactly is causing the failure

- Nuget command = Scaffold-DbContext "Server=10.3.**.**;database=G*ps;user id=***;password=********;Trusted_Connection=True;Integrated Security = false;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Entity

After build suceeded i get this

System.ArgumentException: The string argument 'originalIdentifier' cannot be empty.
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CandidateNamingService.GenerateCandidateIdentifier(String originalIdentifier)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CandidateNamingService.GenerateCandidateIdentifier(DatabaseColumn originalColumn)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.<GetPropertyName>b__18_1(DatabaseColumn c)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpNamer`1.GetName(T item)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpUniqueNamer`1.GetName(T item)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.GetPropertyName(DatabaseColumn column)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitColumn(EntityTypeBuilder builder, DatabaseColumn column)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitColumns(EntityTypeBuilder builder, ICollection`1 columns)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTable(ModelBuilder modelBuilder, DatabaseTable table)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitTables(ModelBuilder modelBuilder, ICollection`1 tables)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>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)
The string argument 'originalIdentifier' cannot be empty.

I would appreciate any help i can get,

Thank You

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (16 by maintainers)

Commits related to this issue

Most upvoted comments

I will add a fix to EF Core Power Tools to create compensating column names in the meantime to unblock, as I assume the fix will be in 6.0 only. Happy to submit a PR.

In that case it is one line fix to stop checking for empty. Check.NotNull is more appropriate. Checked that CSharpUtilities will assign it “_” as name.

Not a regression it has been like this since candidate naming service was introduced.

Don’t ignore the column. Wouldn’t CSharpNamer already replace it with underscores? I don’t even think we need to warn; getting a property with a bunch of underscores makes it pretty obvious what happened. 😉

@smitpatel SQLite does for sure.

@aces32 - The error indicates that while scaffolding there was a column found which had empty string or white spaces as name. It may not be theoretically possible but what has happened. Unless we get schema for the table which caused it, there is no way for us to investigate the issue.

I think you need to share your schema. Which database server version and edition?