Scaffold dbcontext для указанной таблицы c из базы данных oracle выдает ошибку, не связанную с этой таблицей - PullRequest
1 голос
/ 16 января 2020

Я пытаюсь поменять контекст базы данных одной указанной таблицы c в существующей oracle дБ.

dotnet ef dbcontext scaffold 'data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=some.remote.hostname)(PORT=1337))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SVC_NAME)));user id=USER;password=PASS' Oracle.EntityFrameworkCore --table TABLE_NAME --schema SCHEMA_NAME --use-database-names -f

Затем CLI выводит

Build started... Build succeeded.

Далее следует множество предупреждений следующего типа. Ни одна из таблиц, упомянутых в этом предупреждении, не имеет ничего общего с моей таблицей, которую я хочу создать.

Невозможно определить первичный ключ для таблицы 'SCHEMA_NAME.SOME_OTHER_TABLE_NAME'.

Не удается создать тип сущности для таблицы 'SCHEMA_NAME.SOME_OTHER_TABLE_NAME'.

Через некоторое время возникает исключение

System.InvalidOperationException: The types of the properties specified for the foreign key {'SOME_COLUMN'} on entity type 'SOME_TABLE' do not match the types of the properties in the principal key {'SOME_OTHER_COLUMN'} on entity type 'SOME_TABLE'.
   at Microsoft.EntityFrameworkCore.Metadata.Internal.ForeignKey.AreCompatible(IReadOnlyList`1 principalProperties, IReadOnlyList`1 dependentProperties, EntityType principalEntityType, EntityType dependentEntityType, Boolean shouldThrow)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.ForeignKey.AreCompatible(EntityType principalEntityType, EntityType dependentEntityType, MemberInfo navigationToPrincipal, MemberInfo navigationToDependent, IReadOnlyList`1 dependentProperties, IReadOnlyList`1 principalProperties, Nullable`1 unique, Nullable`1 required, Boolean shouldThrow)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType.AddForeignKey(IReadOnlyList`1 properties, Key principalKey, EntityType principalEntityType, Nullable`1 configurationSource)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType.Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType.AddForeignKey(IReadOnlyList`1 properties, IMutableKey principalKey, IMutableEntityType principalEntityType)
   at Microsoft.EntityFrameworkCore.MutableEntityTypeExtensions.GetOrAddForeignKey(IMutableEntityType entityType, IReadOnlyList`1 properties, IMutableKey principalKey, IMutableEntityType principalEntityType)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitForeignKey(ModelBuilder modelBuilder, DatabaseForeignKey foreignKey)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitForeignKeys(ModelBuilder modelBuilder, IList`1 foreignKeys)    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)
The types of the properties specified for the foreign key {'SOME_COLUMN'} on entity type 'SOME_TABLE' do not match the types of the properties in the principal key {'SOME_OTHER_COLUMN'} on entity type 'SOME_TABLE'.

Похоже, моя команда scaffold фактически игнорирует опцию --table и просматривает всю базу данных. Где, по-видимому, есть какая-то неправильная конфигурация, на которую я не могу повлиять.

Есть ли способ обойти это? Могу ли я вручную помостить стол?

Приветствия

...