This may arrive a bit late for you but I'll leave it in case anyone else runs into the same problem.So I finally managed to make Identity 2.0 and Oracle work together. The following steps work if you don't want to make any changes to the default IdentityUser (ex. if you're ok with having a char ID instead of int or long) and just want the tables on your existing Oracle schema. 在Oracle上创建身份表.您可以根据需要更改表名称,只需确保包括必要的列即可使用Identity.您还可以在应用程序上添加任何可能需要的额外列(脚本最初在 Devart ,我将其复制到要点中,以防URL中断):Create Identity tables on Oracle. You can change the table names if you want to, just make sure to include the necessary columns for Identity to work with it. You can also add any extra columns you may need on your application (script originally found on Devart, I copied it to a gist in case URL breaks):要点此处如果使用的是EDMX文件,则需要添加新的连接字符串,因为自动生成的连接字符串将无法工作,因此需要标准的连接字符串.尝试遵循以下模板:If you're using an EDMX file, you need to add a new connection string cause the one that gets generated automatically won't work, you need a standard connection string. Try following this template: <add name="IdentityContext" connectionString="Data Source=localhost:1521/xe;PASSWORD=password;USER ID=username;" providerName="Oracle.ManagedDataAccess.Client" />告诉您的ApplicationDbContext使用新的connectionStringTell your ApplicationDbContext to use your new connectionStringpublic ApplicationDbContext() : base("IdentityContext", throwIfV1Schema: false){} 告诉身份以使用您现有的架构和表.在IdentityModels.cs中找到的ApplicationDbContext定义中添加此方法:Tell Identity to use your existing schema and tables. Add this method inside the ApplicationDbContext definition found in IdentityModels.cs:protected override void OnModelCreating(DbModelBuilder modelBuilder){ base.OnModelCreating(modelBuilder); // MUST go first. modelBuilder.HasDefaultSchema("YOUR_SCHEMA"); // Use uppercase! modelBuilder.Entity<ApplicationUser>().ToTable("AspNetUsers"); modelBuilder.Entity<IdentityRole>().ToTable("AspNetRoles"); modelBuilder.Entity<IdentityUserRole>().ToTable("AspNetUserRoles"); modelBuilder.Entity<IdentityUserClaim>().ToTable("AspNetUserClaims"); modelBuilder.Entity<IdentityUserLogin>().ToTable("AspNetUserLogins");} 重建并仅此而已!Rebuild and thats it!让我知道它是否对您有用!Let me know if it works for you! 这篇关于ASP.NET MVC5-将用户保留在Oracle数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-17 07:01
查看更多