While trying to use code first approach to connect to
Oracle database using
ASP NET C#.
I received the following exception
Oracle.ManagedDataAccess.Client.OracleException: 'ORA-01918: user 'dbo' does not exist'
My current User Is IT_USER
The Reason for the error is that Oracle tried to create my tables which are in my first migration into dbo schema as
SQL Server do, but in Oracle it is a User.
So you need to till
Entity Framework where is my Table Should be
You have two solutions
First is to use
DbModelBuilder.HasDefaultSchema
This will make all of your tables in this schema.
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("IT_USER");
base.OnModelCreating(modelBuilder);
}
Second is to use
System.ComponentModel.DataAnnotations.Schema.Table
This will give you the ability to change the schema when ever you want
[Table("STD_FA_VALIDATION", Schema ="IT_USER")]
public class STD_FA_VALIDATION
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int SGBSTDN_PIDM { get; set; }
public string NAT_CHANGE_IND { get; set; }
public string WORK_IND { get; set; }
public DateTime NAT_PROC_DATE { get; set; }
public DateTime WORK_PROC_DATE { get; set; }
}