"WaferInfo" (
    "Id" NUMBER(10) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL,
    "SerialNo" NUMBER(10) NOT NULL,
    "Station" NVARCHAR2(50),
    "CustomerLotNo" NVARCHAR2(50),
    "WaferId" NVARCHAR2(50),
    "ChipCount" NUMBER(10) NOT NULL,
    "BIN1" NUMBER(10) NOT NULL,   
    "BadCount" NUMBER(10) NOT NULL,
    "Yield" DECIMAL(18, 2) NOT NULL,
    "CreateUser" NVARCHAR2(50),
    "CreateTime" TIMESTAMP(7) NOT NULL,
    CONSTRAINT "PK_WaferInfo" PRIMARY KEY ("Id")
)';
END;

Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-02000: 缺失 ALWAYS 关键字
ORA-06512: 在 line 2
   at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)
   at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteNonQuery(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, OracleException& exceptionForArrayBindDML, OracleConnection connection, Boolean isFromEF)
   at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()
   at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
   at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ORA-02000: 缺失 ALWAYS 关键字
ORA-06512: 在 line 2

因为11g不支持IDENTITY的写法,所以要加上

options.AddDb<DefaultDbContext>(providerName: default, optionBuilder: opt =>
                {
                    opt.UseBatchEF_Oracle(); // EF批量组件
                    opt.UseOracle(b => b.UseOracleSQLCompatibility("11"));
                });

以及不支持超过30个字符的约束名,要在context里面加上

protected override void OnModelCreating(ModelBuilder builder)
        {
            if(Database.ProviderName == DbProvider.Oracle)
            {
                builder.Model.SetMaxIdentifierLength(30);
            }


然后继续update database就行

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐