Relation AspNetUsers Not Found in Identity 2 integration
Posted: Thu 28 Feb 2019 20:16
I am working on an ASP.NET MVC project and I just added ASP.NET Identity 2. For this, I exactly followed instruction in https://www.devart.com/dotconnect/postg ... orial.html and ran the project (I have tried twice in fact). I clicked the Register link which is included by default and the page to add a new user appeared. I then typed email and password, clicked the Register button and an error appeared: "Relation AspNetUsers does not exist".
This is the error message:
Devart.Data.PostgreSql.PgSqlException: no existe la relación «AspNetUsers»
It is in Spanish, "no existe la relación" means "relation does not exist".
This is the code where the exception takes place in Line 166:
Line 164: {
Line 165: var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
Line 166: var result = await UserManager.CreateAsync(user, model.Password);
Line 167: if (result.Succeeded)
Line 168: {
This is part of the stack:
[PgSqlException (0x80004005): no existe la relación «AspNetUsers»]
Devart.Data.PostgreSql.e.f(r A_0) +131
Devart.Data.PostgreSql.r.n() +124
Devart.Data.PostgreSql.PgSqlCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords) +816
Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery) +495
Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior) +6
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12
Devart.Common.Web.Identity.DbDataSource.ExecuteReader(String commandText, List`1 parameterValues, CommandBehavior commandBehavior, Dictionary`2 typeMapping) +298
Devart.Common.Web.Identity.AspNetTable.a(Dictionary`2 A_0) +50
Devart.Common.Web.Identity.AspNetTable.a(String A_0, Object A_1) +56
Devart.Common.Web.Identity.UserTable`2.SelectByUserName(String userName) +20
Devart.Common.Web.Identity.UserStore`3.FindByNameAsync(String userName) +32
Microsoft.AspNet.Identity.UserManager`2.FindByNameAsync(String userName) +56
Microsoft.AspNet.Identity.<ValidateUserName>d__4.MoveNext() +392
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
The connection string is a follows (in web.config):
<connectionStrings>
<add name="DefaultConnection" connectionString="host=localhost;database=dbtest;user id=postgres; password=*********;" providerName="Devart.Data.PostgreSql" />
</connectionStrings>
I created the DB, added a new schema called dbtest and ran the script called Install_identity_tables.sql (to create tables in dbtest schema) located in C:\Program Files (x86)\Devart\dotConnect\PostgreSQL\Web\ASP.NET Identity 2. All the tables appear in my dbtest schema. The public schema (created by default by pgAdmin) is empty.
I noticed that the names of the tables in the script use a combination of upper and lowercase letters while the names of the tables in pgAdmin are all lowercase.
I am using the following product versions:
a) Visual Studio 2017 Version 15.9.4
b) Target .Net Framework 4.6.1
b) PostgreSQL v9.1
c) DevArt dotConnect for PostgreSQL v7.10.1115.0
I will very much appreciate your feedback.
P.D.: I HAVE JUST FOUND THAT IT WORKS CORRECTLY IF IDENTITY TABLES ARE LOCATED IN THE public SCHEMA.
IS THIS A REQUIREMENT? IN MY WEB PROJECT, I USE A DIFFERENT SCHEMA, NOT public.
Respectfully,
Jorge Maldonado
This is the error message:
Devart.Data.PostgreSql.PgSqlException: no existe la relación «AspNetUsers»
It is in Spanish, "no existe la relación" means "relation does not exist".
This is the code where the exception takes place in Line 166:
Line 164: {
Line 165: var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
Line 166: var result = await UserManager.CreateAsync(user, model.Password);
Line 167: if (result.Succeeded)
Line 168: {
This is part of the stack:
[PgSqlException (0x80004005): no existe la relación «AspNetUsers»]
Devart.Data.PostgreSql.e.f(r A_0) +131
Devart.Data.PostgreSql.r.n() +124
Devart.Data.PostgreSql.PgSqlCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords) +816
Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery) +495
Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior) +6
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12
Devart.Common.Web.Identity.DbDataSource.ExecuteReader(String commandText, List`1 parameterValues, CommandBehavior commandBehavior, Dictionary`2 typeMapping) +298
Devart.Common.Web.Identity.AspNetTable.a(Dictionary`2 A_0) +50
Devart.Common.Web.Identity.AspNetTable.a(String A_0, Object A_1) +56
Devart.Common.Web.Identity.UserTable`2.SelectByUserName(String userName) +20
Devart.Common.Web.Identity.UserStore`3.FindByNameAsync(String userName) +32
Microsoft.AspNet.Identity.UserManager`2.FindByNameAsync(String userName) +56
Microsoft.AspNet.Identity.<ValidateUserName>d__4.MoveNext() +392
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
The connection string is a follows (in web.config):
<connectionStrings>
<add name="DefaultConnection" connectionString="host=localhost;database=dbtest;user id=postgres; password=*********;" providerName="Devart.Data.PostgreSql" />
</connectionStrings>
I created the DB, added a new schema called dbtest and ran the script called Install_identity_tables.sql (to create tables in dbtest schema) located in C:\Program Files (x86)\Devart\dotConnect\PostgreSQL\Web\ASP.NET Identity 2. All the tables appear in my dbtest schema. The public schema (created by default by pgAdmin) is empty.
I noticed that the names of the tables in the script use a combination of upper and lowercase letters while the names of the tables in pgAdmin are all lowercase.
I am using the following product versions:
a) Visual Studio 2017 Version 15.9.4
b) Target .Net Framework 4.6.1
b) PostgreSQL v9.1
c) DevArt dotConnect for PostgreSQL v7.10.1115.0
I will very much appreciate your feedback.
P.D.: I HAVE JUST FOUND THAT IT WORKS CORRECTLY IF IDENTITY TABLES ARE LOCATED IN THE public SCHEMA.
IS THIS A REQUIREMENT? IN MY WEB PROJECT, I USE A DIFFERENT SCHEMA, NOT public.
Respectfully,
Jorge Maldonado