Error when using UserManager
I'm running fine in my localhost but got the issue on the server.
I created a new ASP.NET Core 3.0 using Npgsql 4.1.1 and Npgsql.EntityframeworkCore.Postgresql 3.0.1.
Postgresql in Localhost version is : 100001 Postgresql in Server version is : 110005
Whenever I access my dbcontext, it show this exception. ` PostgresException: 42703: column "__normalizedusername_0" does not exist
Npgsql.NpgsqlConnector+<>c__DisplayClass160_0+<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
Npgsql.NpgsqlConnector+<>c__DisplayClass160_0+<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
Npgsql.NpgsqlDataReader.NextResult(bool async, bool isConsuming)
Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, bool async, CancellationToken cancellationToken)
Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor+AsyncQueryingEnumerable<T>+AsyncEnumerator.MoveNextAsync()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync<TSource>(IAsyncEnumerable<TSource> asyncEnumerable, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync<TSource>(IAsyncEnumerable<TSource> asyncEnumerable, CancellationToken cancellationToken)
Microsoft.AspNetCore.Identity.UserManager<TUser>.FindByNameAsync(string userName)
Microsoft.AspNetCore.Identity.SignInManager<TUser>.PasswordSignInAsync(string userName, string password, bool isPersistent, bool lockoutOnFailure)
eSignatureWebApp.Areas.Identity.Pages.Account.LoginModel.OnPostAsync(string returnUrl) in Login.cshtml.cs
`
At first, I suspect that my connectionstring was not specified correctly. So, I tried changing the Configure method in Startup.cs as following
if (env.IsDevelopment())
{
//UpdateDatabase(app);
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
//app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
//app.UseHsts();
}
So when the app open the first times, it ask to click Apply Migrations. I clicked and checked for the log. There was no exception throw. After refreshing the page, it shows the above exception.
I spent many hours trying to figure out what wrong did I do, but I couldn't. So, I guess it might be the bug.
I just found that everything is working fine until I manually specify the culture info.
var cultureInfo = CultureInfo.GetCultureInfo("th-TH"); Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo;
After then, every parameter passed to EF core will just not work.
Confirmed as a bug in EF Core https://github.com/aspnet/EntityFrameworkCore/issues/18831