Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ComptonAlvaro opened this issue Nov 11, 2020 · 7 comments
Assignees
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported regression Servicing-approved type-bug
Milestone

Comments

@ComptonAlvaro
Copy link

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

@smitpatel
Copy link
Contributor

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.

@ajcvickers
Copy link
Contributor

@smitpatel Regression in 5.0?

@ComptonAlvaro
Copy link
Author

Sorry, what does it mean regresion?

Thanks.

@ajcvickers
Copy link
Contributor

@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.

@ComptonAlvaro
Copy link
Author

Thanks for the explanation.

@smitpatel smitpatel self-assigned this Nov 11, 2020
smitpatel added a commit that referenced this issue Nov 11, 2020
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 11, 2020
@smitpatel
Copy link
Contributor

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

@mannok
Copy link

mannok commented Nov 30, 2020

Any workaround on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported regression Servicing-approved type-bug
Projects
None yet
Development

No branches or pull requests

4 participants