无法使用PostgreSQL配置AspNet.Identity [英] Unable to configure AspNet.Identity using PostgreSQL

查看:95
本文介绍了无法使用PostgreSQL配置AspNet.Identity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用SQL Server设置的Web项目,现在必须将其迁移到PostgreSQL。我正在使用Entity Framework 6.0版和最新版本的Microsoft.AspNet.Identity管理用户凭据。我正在使用VS2015和.NET Framework 452。

I have a web project that was setup using SQL Server, and that now has to be migrated to PostgreSQL. I'm using Entity Framework version 6.0 with the latest version of Microsoft.AspNet.Identity to manage user credentials. I'm using VS2015 and .NET Framework 452.

该项目可以与PostgreSQL服务器正常工作,除了AspNet.Identity。当我尝试注册新用户或登录时,我收到 这个问题 。相同的错误,相同的行,但问题是2岁,给出的解决方案对我不起作用(我多次尝试了Add-Migration和Update-Database)。

The project works fine with the PostgreSQL server for everything except AspNet.Identity. When I try to register a new user or do a login I get the same error message described in this question. Same error, same line but the question is 2 years old and the solution given doesn't work for me (I have tried Add-Migration and Update-Database multiple times).

其他所有方法都可行,我检查了一下,我的postgreSQL数据库是否包含与AspNet.Identity相关的任何表,即使它们是在项目使用SQL Server时自动创建的也是如此。

Everything else works, I have checked and my postgreSQL database does NOT contain any tables related to AspNet.Identity even though they were created automatically when the project was using SQL Server. Other model related tables are present and working.

谢谢。

推荐答案

我无法使Microsoft的AspNet.Identity与postgresql一起使用,它似乎旨在与SQL Server一起使用,并且无论您做什么都不承认存在其他数据上下文配置。

I was unable to make Microsoft's AspNet.Identity to work with postgresql, it seems to be designed to work with SQL Server and doesn't acknowledge the presence of a different data context configuration no matter what you do.

借助外部库,我现在可以正常进行所有工作,因此如果有人遇到此问题,我将为我的问题提供答案。

I have everything working now with the aid of an external library so I will provide an answer to my question in case someone else runs into this problem.

我按照以下项目中的说明进行操作(贷记给ncencechan):

I followed the instructions present in the following project (credit to vincechan):

  • PostgreSQL.AspNet.Identity.EntityFramework on github.com

步骤2 有点问题。将项目导入我的解决方案后,我不得不解决其中的参考问题。在程序包管理器控制台中,您可以安装缺少的程序包和/或更新过时的程序包。我的最终配置需要在主项目上使用以下命令:

Step 2 was a bit problematic. After importing the project into my solution I had to resolve reference issues in it. In the Package Manager Console you can Install the missing packages and/or update the ones that are outdated. My final configuration required using:


  • Npgsql 3.2.2 (使用 EntityFramework6。 Npgsql

  • 下载的项目上的
  • Npgsql 2.2.7 (使用 Npgsql.EntityFramework

  • Npgsql 3.2.2 on my main project (using EntityFramework6.Npgsql)
  • Npgsql 2.2.7 on the downloaded project (using Npgsql.EntityFramework)

一切准备就绪后,添加新迁移( Add-Migration< migration-name )并更新您的数据库(更新数据库)。

Once you have everything ready, add a new migration (Add-Migration <migration-name) and update your database (Update-Database).

现在执行创建与身份相关的表的SQL脚本,它们将像使用SQL Server一样不会自动创建。该脚本包含在项目中(文件 PostgreSQLIdentity.sql )。

Now execute the SQL script that creates Identity related tables, they will not be created automatically like the do with SQL Server. The script is included in the project (file PostgreSQLIdentity.sql).

现在一切正常。原谅此答案的格式不正确。

Everything should work now. Forgive the poor formatting of this answer.

这篇关于无法使用PostgreSQL配置AspNet.Identity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆