Abp项目模板使用Oracle数据库包括系统权限管理 by dacong

参考:Abp项目的创建以及Oracle的支持

aspnet-zero-core 使用MySql数据库 http://www.sohu.com/a/162365978_468635

abp项目是可以支持任何数据库的,需要数据库支持entityframework可以无缝移植。

测试环境:oracle11g,abp 3.2.5,vs2017

Abp项目使用Oracle数据库,支持module zero。支持所有用户管理、权限管理、角色管理等。

1、建立项目的时候选择"module zero",

2、添加Oracle.ManagedDataAccess.EntityFramework包从nuget

3、配合app.config,保证oracle的连接正常

4、删除Migrations 目录已日期开头的.cs文件,如201707261347311_Initial_Migration.cs,201710131316266_UpgradedTo_ABP_3.1.cs

5、修改如下文件:

public class MESDbContext : AbpZeroDbContext<Tenant, Role, User>
    {
        //TODO: Define an IDbSet for your Entities...

/* NOTE: 
         *   Setting "Default" to base class helps us when working migration commands on Package Manager Console.
         *   But it may cause problems when working Migrate.exe of EF. If you will apply migrations on command line, do not
         *   pass connection string name to base classes. ABP works either way. by dacong
         */
        public MESDbContext()
            : base("Default")
        {
//Default要与app.config的一致,把oracle自动配置的OracleContext改成default
        }

/* NOTE:
         *   This constructor is used by ABP to pass connection string defined in MESDataModule.PreInitialize.
         *   Notice that, actually you will not directly create an instance of MESDbContext since ABP automatically handles it.
         */
        public MESDbContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {

}

//This constructor is used in tests
        public MESDbContext(DbConnection existingConnection)
         : base(existingConnection, false)
        {

}

public MESDbContext(DbConnection existingConnection, bool contextOwnsConnection)
         : base(existingConnection, contextOwnsConnection)
        {

}
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {

modelBuilder.HasDefaultSchema("ABP");
            base.OnModelCreating(modelBuilder);
            //EntityTypeAssemblyQualifiedName字段过长
            modelBuilder.Entity<NotificationInfo>().Property(e => e.EntityTypeAssemblyQualifiedName).HasColumnName("EntityTypeAssemblyQn");
            modelBuilder.Entity<NotificationSubscriptionInfo>().Property(e => e.EntityTypeAssemblyQualifiedName).HasColumnName("EntityTypeAssemblyQn");
            modelBuilder.Entity<TenantNotificationInfo>().Property(e => e.EntityTypeAssemblyQualifiedName).HasColumnName("EntityTypeAssemblyQn");
        }

public class MESDataModule : AbpModule
    {
        public override void PreInitialize()
        {
            //Database.SetInitializer(new CreateDatabaseIfNotExists<MESDbContext>());
            Configuration.UnitOfWork.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;//ORA-08177
            Configuration.DefaultNameOrConnectionString = "Default";
        }

public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            Database.SetInitializer<MESDbContext>(null);
        }
    }

6、使用程序包管理器控制台里面输入 Add-Migration init

会生成移植文件,如下

public partial class abp_init : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "ABP.AbpAuditLogs",
                c => new
                    {
                        Id = c.Decimal(nullable: false, precision: 19, scale: 0, identity: true),
                        TenantId = c.Decimal(precision: 10, scale: 0),
                        UserId = c.Decimal(precision: 19, scale: 0),
                        ServiceName = c.String(maxLength: 256),
                        MethodName = c.String(maxLength: 256),
                        Parameters = c.String(maxLength: 1024),
                        ExecutionTime = c.DateTime(nullable: false),
                        ExecutionDuration = c.Decimal(nullable: false, precision: 10, scale: 0),
                        ClientIpAddress = c.String(maxLength: 64),
                        ClientName = c.String(maxLength: 128),
                        BrowserInfo = c.String(maxLength: 256),
                        Exception = c.String(maxLength: 2000),
                        ImpersonatorUserId = c.Decimal(precision: 19, scale: 0),
                        ImpersonatorTenantId = c.Decimal(precision: 10, scale: 0),
                        CustomData = c.String(maxLength: 2000),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_AuditLog_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "ABP.AbpBackgroundJobs",
                c => new
                    {
                        Id = c.Decimal(nullable: false, precision: 19, scale: 0, identity: true),
                        JobType = c.String(nullable: false, maxLength: 512),
                        JobArgs = c.String(nullable: false),
                        TryCount = c.Decimal(nullable: false, precision: 5, scale: 0),
                        NextTryTime = c.DateTime(nullable: false),
                        LastTryTime = c.DateTime(),
                        IsAbandoned = c.Decimal(nullable: false, precision: 1, scale: 0),
                        Priority = c.Decimal(nullable: false, precision: 3, scale: 0),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Decimal(precision: 19, scale: 0),
                    })
                .PrimaryKey(t => t.Id)
                .Index(t => new { t.IsAbandoned, t.NextTryTime });
            
            CreateTable(
                "ABP.AbpFeatures",
                c => new
                    {
                        Id = c.Decimal(nullable: false, precision: 19, scale: 0, identity: true),
                        TenantId = c.Decimal(precision: 10, scale: 0),
                        Name = c.String(nullable: false, maxLength: 128),
                        Value = c.String(nullable: false, maxLength: 2000),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Decimal(precision: 19, scale: 0),
                        EditionId = c.Decimal(precision: 10, scale: 0),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_EditionFeatureSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_FeatureSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_TenantFeatureSetting_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("ABP.AbpEditions", t => t.EditionId, cascadeDelete: true)
                .Index(t => t.EditionId);
            
            CreateTable(
                "ABP.AbpEditions",
                c => new
                    {
                        Id = c.Decimal(nullable: false, precision: 10, scale: 0, identity: true),
                        Name = c.String(nullable: false, maxLength: 32),
                        DisplayName = c.String(nullable: false, maxLength: 64),
                        IsDeleted = c.Decimal(nullable: false, precision: 1, scale: 0),
                        DeleterUserId = c.Decimal(precision: 19, scale: 0),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Decimal(precision: 19, scale: 0),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Decimal(precision: 19, scale: 0),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Edition_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "ABP.AbpLanguages",
                c => new
                    {
                        Id = c.Decimal(nullable: false, precision: 10, scale: 0, identity: true),
                        TenantId = c.Decimal(precision: 10, scale: 0),
                        Name = c.String(nullable: false, maxLength: 10),
                        DisplayName = c.String(nullable: false, maxLength: 64),
                        Icon = c.String(maxLength: 128),
                        IsDisabled = c.Decimal(nullable: false, precision: 1, scale: 0),
                        IsDeleted = c.Decimal(nullable: false, precision: 1, scale: 0),
                        DeleterUserId = c.Decimal(precision: 19, scale: 0),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Decimal(precision: 19, scale: 0),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Decimal(precision: 19, scale: 0),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ApplicationLanguage_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    { "DynamicFilter_ApplicationLanguage_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "ABP.AbpLanguageTexts",
                c => new
                    {
                        Id = c.Decimal(nullable: false, precision: 19, scale: 0, identity: true),
                        TenantId = c.Decimal(precision: 10, scale: 0),
                        LanguageName = c.String(nullable: false, maxLength: 10),
                        Source = c.String(nullable: false, maxLength: 128),
                        Key = c.String(nullable: false, maxLength: 256),
                        Value = c.String(nullable: false),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Decimal(precision: 19, scale: 0),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Decimal(precision: 19, scale: 0),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_ApplicationLanguageText_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);

。。。。。。省略,这个cs或生成Oracle的表的。
7、 update-database
无红色错误,为成功。
PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201712091925426_abp_init].
Applying explicit migration: 201712091925426_abp_init.
Running Seed method.
查看Oracle数据库,有如下的表,AbpUsers已经包含admin用户
__MigrationHistory
AbpAuditLogs
AbpBackgroundJobs
AbpEditions
AbpFeatures
AbpLanguages
AbpLanguageTexts
AbpNotifications
AbpNotificationSubscriptions
AbpOrganizationUnits
AbpPermissions
AbpRoles
AbpSettings
AbpTenantNotifications
AbpTenants
AbpUserAccounts
AbpUserClaims
AbpUserLoginAttempts
AbpUserLogins
AbpUserNotifications
AbpUserOrganizationUnits
AbpUserRoles
AbpUsers

8、给web项目也增加racle.ManagedDataAccess.EntityFramework,并修改web.cong。

9、启动web项目。

目前这个版本在web项目第一次启动时或保存,刷新后可以正常使用。

CAC.MES.Web.Controllers.HomeController   - An error occurred while preparing the command definition. See the inner exception for details.
System.Data.Entity.Core.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details. ---> System.NotSupportedException: A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe.

Abp项目模板使用Oracle数据库包括系统权限管理相关推荐

  1. abp如何连接oracle,Abp项目模板使用Oracle数据库

    [实例简介] Abp项目模板使用Oracle11g数据库包括系统权限管理,Abp.Zero [实例截图] [核心代码] 0df058ea-1862-4668-8b8e-11d4ab5618c3 ├── ...

  2. aix oracle 登录用户,AIX 系统及 Oracle 数据库用户权限管理

    AIX 系统及Oracle 数据库用户权限管理 1.AIX 系统用户管理.系统用户管理 1.1 对于root 用户.在aix 系统中root 账户是具有最高特权的,因此保护好root 的密码尤为重要, ...

  3. oracle青蛙工具,要对Oracle数据库进行远程管理,可以采用的工具是( )。

    要对Oracle数据库进行远程管理,可以采用的工具是( ). 更多相关问题 爱新觉罗·溥仪是清王朝最后一位帝王.他在位时年号(). PowerPoint中不应用设计模板,将无法设计幻灯片. 手工电弧及 ...

  4. 详解:MySQL数据库的权限管理和运维实操

    详解:MySQL数据库的权限管理 一.MYSQL权限简介 关于mysql的权限简单的理解就是mysql允许你做你权利以内的事情,不可以越界.比如只允许你执行select操作,那么你就不能执行updat ...

  5. Oracle数据库模式对象管理

    实验四 Oracle数据库模式对象管理 一.预习报告 一. 实验目的 1) 掌握表的创建与管理. 2) 掌握索引的创建与管理. 3) 掌握视图的创建与管理. 4) 掌握序列的创建与管理. 5) 了解簇 ...

  6. 数据库—用户权限管理(三十三)

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 目录 前言 一.概述 二.用户权限类型 ​三.用户赋权 四.权限删除 五.用户删除 前言 数据库用户权限管理是指对数据库用户的权限进行 ...

  7. oracle数据库有哪些权限,ORACLE数据库中权限有哪些?

    1 权限 Oracle数据库有两种途径获得权限,它们分别为: ① DBA直接向用户授予权限. ② DBA将权限授予角色(一个命名的包含多个权限的集合),然后再将角色授予一个或多个用户. 使用角色能够更 ...

  8. Oracle用户角色权限管理

    (一)什么叫用户(user): A user is a name defined in the database that can connect to and access objects. 用户是 ...

  9. Oracle用户和权限管理

    文章目录 一.数据库管理员 二.用户管理 1.创建用户 2.修改用户的密码 3.锁定/解锁用户 4.修改用户表空间配额 5.删除用户 三.权限管理 1.系统权限 2.对象权限 3.角色 4.授于/收回 ...

最新文章

  1. Installshield 2015 实现检测某安装文件是否存在并运行安装
  2. 求生之路怎么显示服务器,求生之路怎么搭建云服务器
  3. boost::function_types::parameter_types用法的测试程序
  4. 数据库表设计、 数据库分层、myslq水平拆分、oracle表分区
  5. 视频云下半场 向前走还是向“厚”走?
  6. .NET跨平台之Sake和KoreBuild
  7. mysql导入source注意点
  8. 如何用PPT编制方案 (2)PPT内容的逻辑表达
  9. 金庸群侠传1android,96版金庸群侠传1手机版
  10. spring mvc
  11. [JavaScript 刷题] 搜索 - 腐烂的橘子, leetcode 994
  12. 全新上线,亿图图示小程序
  13. 数据分析报告的 6 个步骤
  14. 实现一个添加标签的功能
  15. 6-1 使用函数验证哥德巴赫猜想 (20 分)
  16. jquery 照片墙抽奖_使用jQuery滑动面板照片墙画廊
  17. 微笑的力量:成人大脑中负责学习婴儿情绪的网络
  18. 微信怎样加入精准粉丝
  19. 微信小程序使用色彩字体图标(笔录)
  20. 00后的文化消费观是怎样的

热门文章

  1. java毕业设计网上书城系统mybatis+源码+调试部署+系统+数据库+lw
  2. 计算机毕业设计Java小动物领养网站(源码+系统+mysql数据库+Lw文档)
  3. 旅游的HTML语言,html旅游网站
  4. 社区儿童计算机活动总结,【最新】社区亲子活动工作总结
  5. Minio服务器上传图片视频访问不了
  6. 服务器100M带宽视频流媒体支持多少用户在线访问?(计算一下就知道了)
  7. Sublime Text主题皮肤安装与切换使用方法
  8. 小程序获取当前时间戳
  9. 服务器远程重新做系统吗,服务器怎么远程重装系统
  10. 盗版猖獗、开发难……VR游戏进阶之路“道阻且长”