gpt4 book ai didi

PostgreSQL + Npgsql 连接器 + MVC 和 SimpleMembership 不工作

转载 作者:行者123 更新时间:2023-11-29 12:38:08 25 4
gpt4 key购买 nike

我已经在没有网络安全的情况下测试了数据库连接并且它可以工作。我遵循了 Brice Lambson 的教程 http://brice-lambson.blogspot.com.es/2012/10/entity-framework-on-postgresql.html

但是当我使用

WebSecurity.InitializeDatabaseConnection("myContext", "UserProfile", "UserId", "UserName", autoCreateTables: false);

我得到这个异常:

System.InvalidOperationException was caught
HResult=-2146233079
Message=No user table found that has the name "UserProfile".
Source=WebMatrix.WebData
StackTrace:
in WebMatrix.WebData.SimpleMembershipProvider.ValidateUserTable()
in WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables)
in WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables)
in WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables)
in Glink.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() en c:\Users\...\InitializeSimpleMembershipAttribute.cs:line 46
InnerException: Npgsql.NpgsqlException
HResult=-2147467259
Message=ERROR: 42601: Syntax error near «[»
Source=Npgsql
ErrorCode=-2147467259
BaseMessage=Syntax error near «[»
Code=42601
Detail=""
ErrorSql=SELECT [UserId] FROM [UserProfile] WHERE (UPPER([UserName]) = ((E'Z')))
File=src\backend\parser\scan.l
Hint=""
Line=1002
Position=8
Routine=scanner_yyerror
Severity=ERROR
Where=""
StackTrace:
in Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext()
in Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
in Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
in Npgsql.ForwardsOnlyDataReader.NextResult()
in Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)
in Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
in Npgsql.NpgsqlCommand.ExecuteScalar()
in WebMatrix.Data.Database.QueryValue(String commandText, Object[] args)
in WebMatrix.WebData.DatabaseWrapper.QueryValue(String commandText, Object[] parameters)
in WebMatrix.WebData.SimpleMembershipProvider.GetUserId(IDatabase db, String userTableName, String userNameColumn, String userIdColumn, String userName)
in WebMatrix.WebData.SimpleMembershipProvider.ValidateUserTable()
InnerException:

我猜 NpgSql 无法准备好与 SimpleMerbership 一起工作,但我想知道你们中是否有人尝试过这个。谢谢!!

最佳答案

您应该尝试 Daniel Nauck 的 AspSQLProvider:http://dev.nauck-it.de/projects/show/aspsqlprovider

它是 ASP.NET 2.0+ 成员资格、角色、配置文件和 session 状态存储提供程序的 PostgreSQL 实现。

希望对你有帮助。

关于PostgreSQL + Npgsql 连接器 + MVC 和 SimpleMembership 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17830693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com