Abp项目模板使用Oracle数据库包括系统权限管理
来源:互联网 发布:推广淘宝优惠券赚钱 编辑:程序博客网 时间:2024/06/05 12:05
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);
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.
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数据库包括系统权限管理
- ABP+AdminLTE+Bootstrap Table权限管理系统第一节--使用ASP.NET Boilerplate模板创建解决方案
- ABP+AdminLTE+Bootstrap Table权限管理系统第二节--在ABP的基础做数据库脚本处理
- [ABP开源项目]--vue+vuex+vue-router+EF的权限管理系统
- 使用.net core ABP和Angular模板构建博客管理系统(创建后端服务)
- 使用.net core ABP和Angular模板构建博客管理系统(实现博客列表页面)
- 使用.net core ABP和Angular模板构建博客管理系统(完善前台服务)
- 使用.net core ABP和Angular模板构建博客管理系统(实现编辑页面功能)
- ABP module-zero +AdminLTE+Bootstrap Table+jQuery权限管理系统第十五节--缓存小结与ABP框架项目中 Redis Cache的实现
- ABP+AdminLTE+Bootstrap Table权限管理系统一期
- ABP module-zero +AdminLTE+Bootstrap Table+jQuery权限管理系统第十七节--Quartz与ABP框架Abp.Quartz及扩展
- ABP+AdminLTE+Bootstrap Table权限管理系统第六节--abp控制器扩展及json封装
- 使用.net core ABP和Angular模板构建博客管理系统(实现自己的业务逻辑)
- Oracle数据库权限管理
- oracle数据库权限管理
- ABP+AdminLTE+Bootstrap Table权限管理系统第十一节--bootstrap table之用户管理列表
- ABP module-zero +AdminLTE+Bootstrap Table+jQuery权限管理系统第十六节--SignalR与ABP框架Abp.Web.SignalR及扩展
- ABP module-zero +AdminLTE+Bootstrap Table+jQuery权限管理系统第十三节--RBAC模式及ABP权限管理(附赠福利)
- java基本数据类型
- 小笔记 DLL导出 和 Lib引用
- Python Bool加减后变int
- 字符串去重---试试手
- 利用JNI技术在Android中调用C++形式的OpenGL ES 2.0函数
- Abp项目模板使用Oracle数据库包括系统权限管理
- IntelliJ IDEA License Server本地搭建教程
- 如何解决插入mysql反斜杠消失
- swing awt学习笔记
- CF 462D(Appleman and Tree-树形dp)
- Java--集合学习记录(1)-Queue
- ARP命令详解
- 置信区间
- mybatis教程