Typescript DTO generation for Identity ApplicationUser

When the Identity user gets generated via TS it creates error:

TS2449: Class ‘IdentityUser_1’ used before its declaration.

I think because it inherits from a generic class. This class gets generated after it is referenced

export class IdentityUser extends IdentityUser_1<string>
{

    public constructor(init?: Partial<IdentityUser>) { super(init); (Object as any).assign(this, init); }
}

I do have an ApplicationUserResponse model with flat properties that is used on all IReturn values but I am using autocrud so if I specify any ICreateDb<TEntity> that has a reference to ApplicationUser table then the application user gets generated in DTO. I can’t exclude it from generation as then it will be a missing reference.

Is there anyway to make the Identity user generate in the correct order?

You cant manage EF Data Models with AutoQuery (OrmLite), you should also be using EF’s Identity providers to modify its User tables. You also shouldn’t have any implementation dependencies, e.g. Microsoft.AspNetCore.Identity in your ServiceModel DTOs project.

But you should be able to query it by creating a Flat DTO with all the properties you want to return. Use [Alias] to map it back to the AspNetUsers Users table, e.g:

[Alias("AspNetUsers")]
public class AppUser
{
  // public properties you want returned
}

Since managing User data is more restrictive with ApplicationUser Identity Table I typically create a separate 1:1 UserInfo table for managing non Auth related User information which I automatically create in the Registration Identity UI Page, e.g Register.razor.

1 Like

Thanks, that worked perfectly!

I really appreciate all your help Mythz. ServiceStack has the best support.

1 Like