EF Core Scaffolding Issue with Indexes — oracle-tech

    Forum Stats

  • 3,716,133 Users
  • 2,242,960 Discussions
  • 7,845,840 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

EF Core Scaffolding Issue with Indexes

055f3c76-df86-4f5d-bc24-15c2e82b36cb
edited August 2019 in ODP.NET

We are trying to scaffold a number of our schemas with a consistent issue almost every time:  System.ArgumentNullException: Value cannot be null.

Parameter name: column

   at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)

   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.GetPropertyName(DatabaseColumn column)

   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()

   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)

   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)

   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitIndex(EntityTypeBuilder builder, DatabaseIndex index)

   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitIndexes(EntityTypeBuilder builder, ICollection`1 indexes)

   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, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, 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_1.<.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)

I was able to try around a dozen schemas running the following in CLI and only one schema finished without the above exception.  Seeing it was having trouble visiting indexes, I looked in ALL_INDEXES and confirmed that the one schema that finished had only indexes of type NORMAL.

Scaffold-DbContext "User ID=/;Data Source=<instance>" Oracle.EntityFrameworkCore -schema <schema> –force -verbose

I did a little research to see if this is an EF Core issue and found this:  https://github.com/aspnet/EntityFrameworkCore/issues/10416   so it seems like the index type is the responsibility of the provider and that function-based indexes need to be addressed.

Is anyone else having trouble scaffolding with non-NORMAL indexes?  Are there any work arounds?  I tried even specifying just one table that only had normal indexes and that still went through the same logic that produced this error.

Answers

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,753 Employee
    edited August 2019

    I would expect developers using beta 1 or beta 2 would hit this issue.

    Prior to beta 3, an exception like the one you mention is returned whenever a table used a function based index. Post-beta 3, we fixed it so that it does NOT throw an exception. However the function based index will NOT be scaffolded as indicated in the README.

    * Scaffolding a table that uses Function Based Indexes is supported. However, the index will NOT be scaffolded.

Sign In or Register to comment.