С Nu-Get я установил
Oracle.EntityFrameworkCore version 2.19.60
Microsoft.EntityFrameworkCore.Design version 2.26
Команда, которую я запустил в консоли диспетчера пакетов
Scaffold-DbContext "User Id=john;Password=doe;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=example.com)(PORT=1776)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=example.com)(failover_mode=(type=select)(method=basic)(failover=on)(load_balance=on))));" Oracle.EntityFrameworkCore -OutputDir Models -Force
Я удалил имя пользователя, пароль и имя хоста, имя службы и заменил его на Джон, Доу и example.com. Моя строка подключения действительна, и я проверил ее.
Вывод
Build started...
Build succeeded.
Unable to identify the primary key for table 'JOHN.TBL_ERROR_CORRECTIONS'.
Unable to generate entity type for table 'JOHN.TBL_ERROR_CORRECTIONS'.
Unable to identify the primary key for table 'JOHN.PASSWORD_HISTORY'.
Unable to generate entity type for table 'JOHN.PASSWORD_HISTORY'.
System.InvalidOperationException: The property list {'TicketSerialNumber', 'TicketSerialNumber'} cannot be used, because it contains a duplicate - 'TicketSerialNumber'.
at Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType.AddKey(IReadOnlyList`1 properties, ConfigurationSource configurationSource)
at Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.HasKeyInternal(IReadOnlyList`1 properties, Nullable`1 configurationSource)
at Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.PrimaryKey(IReadOnlyList`1 properties, ConfigurationSource configurationSource)
at Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.PrimaryKey(IReadOnlyList`1 propertyNames, ConfigurationSource configurationSource)
at Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder.HasKey(String[] propertyNames)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitPrimaryKey(EntityTypeBuilder builder, DatabaseTable table)
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)
The property list {'TicketSerialNumber', 'TicketSerialNumber'} cannot be used, because it contains a duplicate - 'TicketSerialNumber'.
Я новичок в EntityFramework и не уверен, как это отладить. Моя база данных Oracle 11,2G
Вот таблица, которая содержит TicketSerialNumber
CREATE TABLE "JOHN"."TICKETS"
( "TICKET_SERIAL_NUMBER" NUMBER NOT NULL ENABLE,
"BOOK_NUMBER" NUMBER NOT NULL ENABLE,
"TICKET_NUMBER" NUMBER NOT NULL ENABLE,
"CONDUCTOR_NUMBER" NUMBER NOT NULL ENABLE,
"CONDUCTOR_NAME" VARCHAR2(75 CHAR) NOT NULL ENABLE,
"REMITTANCE_DATE" DATE NOT NULL ENABLE,
"REMITTANCE_TOM" NUMBER NOT NULL ENABLE,
"REMITTANCE_2C1_FORM" VARCHAR2(8 BYTE) NOT NULL ENABLE,
"REMITTANCE_SHIFT_ID" NUMBER NOT NULL ENABLE,
CONSTRAINT "TICKETS_PK" PRIMARY KEY ("TICKET_SERIAL_NUMBER")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 42991616 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USER_DATA" ENABLE
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 0 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 461373440 NEXT 131072 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)