Oracle.ManagedDataAccess.EntityFramework - ORA-01918: user 'dbo' does not exist

痞子三分冷 提交于 2019-11-27 09:12:43
Отгонтөгс Миймаа

I had the same problem and it was resolved by Thiago Lunardi's response. Thank you. I didn't have enough reputation to vote up your response. To mention here, I succeeded after setting my schema name in UPPERCASE.

Put this in your Context file under your new dbContext class, like this:

public partial class MyAppContext : DbContext
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.HasDefaultSchema("UPPERCASE_SCHEMA_NAME");
...

I solve this just setting the default schema at modelBuilder

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.HasDefaultSchema("MyOracleSchema");

    // ...
}

Setting default schema didn't work for me. I found the solution by customizing migrations history table to set a different schema.

You can find a solution here: LINK.

Aditya

User Dbo also comes in case of missing fully qualified name of the Table. Which may not map to the right Table in the database.

If you use Automatic Migrations (as I was), then note: modelBuilder.HasDefaultSchema whouldn't help until you switch to explicit migrations.

From Oracle Docs:

Code First Automatic Migrations is limited to working with the dbo schema only. Due to this limitation it is recommended to use code-based migrations, that is, add explicit migrations through the Add-Migration command

in Code First you can use the DataAnnotations for Table .

[Table("Emplpoyee",Schema="YOUR SCHEMA NAME"]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!