OracleException:ORA-01918:user' dbo'不存在

时间:2018-03-28 10:49:53

标签: c# oracle entity-framework

尝试使用EntityFramework 6连接到远程oracle db时出现此错误。我已经看到类似的问题 Oracle.ManagedDataAccess.EntityFramework - ORA-01918: user 'dbo' does not exist 但是我的模式名称实际上是小写的(连接==模式,对吧?) - 我用Oracle SQL开发人员检查了它。我的连接字符串

  

DATA SOURCE =     (DESCRIPTION =       (ADDRESS =(PROTOCOL = TCP)(HOST = srvhost)(PORT = 1521))       (CONNECT_DATA =         (SERVER = DEDICATED)         (SERVICE_NAME = cmmd)       )     ); PERSIST SECURITY INFO = True; USER ID = usr; PASSWORD = pwd; Max Pool Size = 40; Incr Pool Size = 1; Decr Pool Size = 1;

因此此代码无效

builder.HasDefaultSchema("ORACLE"); // error ORA-01918: user 'ORACLE' does not exist

builder.HasDefaultSchema("oracle"); // error ORA-01918: user 'oracle' does not exist

Oracle SQL developer 编辑1:

public class OracleDbContext : DbContext
{
    public OracleDbContext() : base(new OracleConnection(Tools.GetConnectionString()), true)
    {

    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        MapMonitoringObject(modelBuilder);
    }

    public DbSet<MonitoringObject> MonitoringObjects { get; set; }

    private void MapMonitoringObject (DbModelBuilder builder)
    {
        //builder.HasDefaultSchema("");
    }

}

1 个答案:

答案 0 :(得分:1)

事实证明,“架构”意味着用户,因为存储在dba_users中。所以我查询它,选择了一个,在HasDefaultSchema中添加并且错误消失了(但现在返回null)。我真的试图在Oracle术语中找到“架构”的含义,但它很容易与“数据库”概念混淆。