可能我做错了什么,但在这里:
我正在尝试在 OracleXE 版本 10.2.0.1.0 中使用 subsonic.migrations 创建数据库。我安装了 ODP v 10.2.0.2.20。
这是我的 app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="test" connectionString="Data Source=XE; User Id=test; Password=test;"/>
</connectionStrings>
<SubSonicService defaultProvider="test">
<providers>
<clear/>
<add name="test" type="SubSonic.OracleDataProvider, SubSonic" connectionStringName="test" generatedNamespace="testdb"/>
</providers>
</SubSonicService>
</configuration>
这是我的第一次迁移:
public class Migration001_Init : Migration {
public override void Up() {
//Create the records table
TableSchema.Table records = CreateTable("asdf");
records.AddColumn("RecordName");
}
public override void Down() {
DropTable("asdf");
}
}
当我运行 sonic.exe 时,我得到了这个异常:
Setting ConfigPath: 'App.config'
Building configuration from D:\Users\carlucci\Documents\Visual Studio 2008\Projects\Wum\Wum.Migration\App.config
Adding connection to test
ERROR: Trying to execute migrate
Error Message: System.Data.OracleClient.OracleException: ORA-02253: especifica‡Æo de restri‡Æo nÆo permitida aqui
at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc)
at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciRowidDescriptor& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
at SubSonic.OracleDataProvider.ExecuteQuery(QueryCommand qry) in D:\@SubSonic\SubSonic\SubSonic\DataProviders\OracleDataProvider.cs:line 350
at SubSonic.DataService.ExecuteQuery(QueryCommand cmd) in D:\@SubSonic\SubSonic\SubSonic\DataProviders\DataService.cs:line 544
at SubSonic.Migrations.Migrator.CreateSchemaInfo(String providerName) in D:\@SubSonic\SubSonic\SubSonic.Migrations\Migrator.cs:line 249
at SubSonic.Migrations.Migrator.GetCurrentVersion(String providerName) in D:\@SubSonic\SubSonic\SubSonic.Migrations\Migrator.cs:line 232
at SubSonic.Migrations.Migrator.Migrate(String providerName, String migrationDirectory, Nullable`1 toVersion) in D:\@SubSonic\SubSonic\SubSonic.Migrations\Migrator.cs:line 50
at SubSonic.SubCommander.Program.Migrate() in D:\@SubSonic\SubSonic\SubCommander\Program.cs:line 264
at SubSonic.SubCommander.Program.Main(String[] args) in D:\@SubSonic\SubSonic\SubCommander\Program.cs:line 90
Execution Time: 379ms
我究竟做错了什么?
非常感谢您的帮助:)
安德烈·卡鲁奇
更新:正如 Anton 所指出的,问题是亚音速 OracleSqlGenerator。它正在尝试使用此 sql 创建模式表:
CREATE TABLE SubSonicSchemaInfo (
version int NOT NULL CONSTRAINT DF_SubSonicSchemaInfo_version DEFAULT (0)
)
这在甲骨文上不起作用。正确的 sql 是:
CREATE TABLE SubSonicSchemaInfo (
version int DEFAULT (0),
constraint DF_SubSonicSchemaInfo_version primary key (version)
)
有趣的是,由于这是亚音速迁移执行的第一个 sql,所以没有人在 oracle 上测试过它。