SELECT @@IDENTITY not scoped by DB object?
Date : March 29 2020, 07:55 AM
hope this fix your issue Turns out that SELECT @@IDENTITY is scoped by session. In ADO, this is handled via the connection. In DAO, we have to use Workspaces to isolate the scope. The following code works as expected: Sub IdentitySucceed()
Dim ws1 As DAO.Workspace, ws2 As DAO.Workspace
Dim db1 As DAO.Database, db2 As DAO.Database
Dim id1 As Long, id2 As Long, DbPath As String
CurrentDb.Execute "CREATE TABLE LocalDummy (Col1 AUTOINCREMENT, Col2 INT)", dbFailOnError
'The workspace names need not be unique;'
' we'll use the objects themselves (ws1 and ws2) to keep them straight'
Set ws1 = DAO.CreateWorkspace("TempWS", "Admin", "")
Set ws2 = DAO.CreateWorkspace("TempWS", "Admin", "")
DbPath = Application.CurrentProject.Path & "\" & _
Application.CurrentProject.Name
Set db1 = ws1.OpenDatabase(DbPath)
Set db2 = ws2.OpenDatabase(DbPath)
db1.Execute "INSERT INTO LocalDummy(Col2) VALUES(Null)", dbFailOnError
id1 = db1.OpenRecordset("SELECT @@IDENTITY")(0)
db2.Execute "INSERT INTO LocalDummy(Col2) VALUES(Null)", dbFailOnError
id2 = db2.OpenRecordset("SELECT @@IDENTITY")(0)
Debug.Print id1, id2
Debug.Print db1.OpenRecordset("SELECT @@IDENTITY")(0), _
db2.OpenRecordset("SELECT @@IDENTITY")(0), _
CurrentDb.OpenRecordset("SELECT @@IDENTITY")(0)
End Sub
1 2
1 2 2
|
How to customize ASP.NET Identity to handle users scoped within applications?
Date : March 29 2020, 07:55 AM
I wish did fix the issue. What you're describing sounds like multi-tenancy. I've answered a related question here, and provided a library to implement it
|
Cannot resolve scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[IdentityServerSample.Models.ApplicationUser]'
Tag : chash , By : ArmHead
Date : March 29 2020, 07:55 AM
This might help you You need a scope to resolve dependencies registered as scoped. To create it you can use the following: using(var scope = app.ApplicationServices.CreateScope())
{
//Resolve ASP .NET Core Identity with DI help
var userManager = (UserManager<ApplicationUser>)scope.ServiceProvider.GetService(typeof(UserManager<ApplicationUser>));
// do you things here
}
|
ASP.NET Core 3: Cannot resolve scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Alpha.Models.Identity.User]'
Tag : chash , By : picamiolo
Date : March 29 2020, 07:55 AM
To fix this issue From the screenshot you've included, it shows that you've got the following line in Startup.Configure: ApplicationDbContext.CreateAdminAccount(app.ApplicationServices, Configuration)
.Wait();
public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider)
{
ApplicationDbContext.CreateAdminAccount(serviceProvider, Configuration)
.Wait();
}
public class Program
{
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
using (var scope = host.Services.CreateScope())
{
var serviceProvider = scope.ServiceProvider;
var config = serviceProvider.GetRequiredService<IConfiguration>();
await ApplicationDbContext.CreateAdminAccount(serviceProvider, config);
}
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
// ...
}
|
ASP.NET MVC5 Identity issue with User.Identity.GetUserId() during login process
Date : March 29 2020, 07:55 AM
Hope this helps If you are using an implementation like the default AccountController::Register, note that this action signs in the new user after the registration, i.e.: await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
|