Efcore: Error: The string argument 'name' cannot be empty when I scaffolding Sqlite database

Created on 11 Nov 2020  路  7Comments  路  Source: dotnet/efcore

I have a Sqlite database that has this table:

CREATE TABLE [Mytable](
  [ID] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, 
  [Name] VARCHAR NOT NULL UNIQUE, 
  UNIQUE([Name]));

I am trying to scaffold this database, I am using this command:

Scaffold-DbContext "Filename=Planos.sqlite" Microsoft.EntityFrameworkCore.Sqlite -UseDatabaseNames -OutputDir Entidades

But I get this error:

System.ArgumentException: The string argument 'name' cannot be empty.
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
   at Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder.HasIndex(String[] propertyNames, String name)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitUniqueConstraint(EntityTypeBuilder builder, DatabaseUniqueConstraint uniqueConstraint)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitUniqueConstraints(EntityTypeBuilder builder, ICollection`1 uniqueConstraints)
   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, ModelReverseEngineerOptions options)
   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, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize)
   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 'name' cannot be empty.

Thanks.

Microsoft.Data.Sqlite version: 3.33.0
Target framework: (NET 5.0)
Operating system: Windows 10

Servicing-approved area-scaffolding closed-fixed customer-reported regression type-bug

Most helpful comment

@smitpatel Regression in 5.0?

All 7 comments

We added conditional code in indexes to call overload based on name being empty or non-empty.
We did not do the same for unique constraint which also creates indexes.
The problematic part in the code is that unique constraint does not have a name.

@smitpatel Regression in 5.0?

Sorry, what does it mean regresion?

Thanks.

@ComptonAlvaro In means that something that was working in the previous release (3.1) is unintentionally broken in the latest release (5.0). As opposed to something broken in 5.0 that was also broken in 3.1.

Thanks for the explanation.

Created PR fix against 5.0 branch. Will re-target based on if we decide to patch this or not.

Any workaround on this?

Was this page helpful?
0 / 5 - 0 ratings