0

I am trying to use the MVC (version 5) identity membership provider with an Oracle database (11 g). I have already created a database and installed all the necessary tables (ORA_ASPNET_APPLICATIONS, ORA_ASPNET_USERS, etc). I have also downloaded Oracle Developer Tools for Visual Studio, and have installed and referenced the Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework assemblies. When I try to add a new user, the application breaks at this line:

var result = await UserManager.CreateAsync(user, model.Password);

And I get the following error:

ORA-01918: user 'dbo' does not exist

I looked at the stack track and -- based on the contents -- it looks like the application is trying to create a new database (see below):

System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)

I'm not sure why, though, since the database already exists. I have only one connection string in my web.config, and it points to the Oracle database I created.

Has anyone been able to get the MVC membership provider to work with Oracle? If so, can anyone provide me with any assistance? I already looked at this link -- Oracle.ManagedDataAccess.EntityFramework - ORA-01918: user 'dbo' does not exist -- but I'm not using code-first, so I don't think any of the suggestions apply in my situation.

My connection string is below:

 <add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=MyOracleAccountUserName;Password=MyOracleAccountPassword;Data Source=MyOracleDataSource" />

I don't think it's the connection string, though. I also tried overriding the OnModelCreating method as follows:

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


        modelBuilder.Entity<ApplicationUser>().ToTable("ORA_ASPNET_USERS");
        modelBuilder.Entity<IdentityRole>().ToTable("ORA_ASPNET_ROLES");
        modelBuilder.Entity<IdentityUserRole>().ToTable("ORA_ASPNET_USERSINROLES");


    }

But, when I do that, I get a different error: ORA-00904: "Extent1"."UserName": invalid identifier.

Community
  • 1
  • 1
  • Your connection string is wrong? Show us your connection string in web.config – Rosdi Kasim Sep 21 '16 at 13:11
  • I added the connection string – user227269 Sep 21 '16 at 13:23
  • I figured it out. The tables in my database were based on the ASP.Net Membership model, not on the Identity model. I had used the database table scripts as provided by Oracle. So, I had to scrap those and create new ones using migrations. Once I did that, I was able to create new users. – user227269 Sep 21 '16 at 19:18
  • You should post your answer... somebody else might find it beneficial. – Rosdi Kasim Sep 22 '16 at 12:25

1 Answers1

0

modelBuilder.HasDefaultSchema("MSN");

your schema name should be UPPERCASE

solarsoft0
  • 54
  • 4