研究了好久了

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

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐