ABP 框架使用postgresql数据库

研究了好久了

1. 在“*.EntityFramework”和“*.Web”两个项目安装npgsql和npgsql 的entityframework支持

Install-Package Npgsql
Install-Package EntityFramework6.Npgsql

2. web.config配置

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
    </providers>
</entityFramework>
<system.data>
    <DbProviderFactories>
      <remove invariant="Npgsql"></remove>
      <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql" />
    </DbProviderFactories>
</system.data>
<connectionStrings>
    <add name="Default" connectionString="Server=localhost;Database=db; User Id=user;Password=123456;" providerName="Npgsql" />
    <add name="Abp.Redis.Cache" connectionString="localhost" />
</connectionStrings>

3.  删除“*.EntityFramework”项目中 Migrations 路径下除 "Seed"文件夹和“Configuration.cs”文件的其他文件

4. 修改“*.EntityFramework”项目中 Migrations 路径下的“Configuration.cs”文件

public Configuration()
{
    AutomaticMigrationsEnabled = false;
    ContextKey = "AbpZeroTemplate";
    SetSqlGenerator("Npgsql", new Npgsql.NpgsqlMigrationSqlGenerator()); //添加
}

5. 将“*.Web”项目设为启动项目,打开 程序包管理器控制台,将“*.EntityFramework”项目设置 程序包管理器控制台的默认项目,开始数据库迁移

Add-Migration "AbpZero_Installed"

6. 运行上诉命令后,在“*.EntityFramework”项目中Migrations 路径下生成了“********_Installed.cs”的文件。打开此文件检查如下内容maxLength是否超过10485760,若大于10485760,则修改为10485760

搜索 AbpBackgroundJobs 的 JobArgs

搜索 AbpLanguageTexts  的 Value

搜索 AbpNotifications   的 Data,UserIds,enantIds,ExcludedUserIds

搜索 AbpTenantNotifications      的 Data

搜索 AppBinaryObjects          的 Bytes

搜索 AppChatMessages     的 Message

搜索 AppFriendships         的 FriendTenancyName

 7. 打开 程序包管理器控制台,运行 Update-Database

Update-Database

 

转载于:https://my.oschina.net/u/138005/blog/758706

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值