DB Schemas not being detected RRS feed

  • Question

  • User297458589 posted

    I have 2 applications named ManagementStudio and DocumentStudio. DocumentStudio references ManagementStudio via its compiled dlls. However, when I login via DocumentStudio, I get an error asking for IdentityUserClaim. I then proceeded to create a IdentityUserClaim table that looked like this ManagementStudio.IdentityUserClaim.

    However, that didn't work as well as DocumentStudio does not recognise ManagementStudios schema for some reason.

    I also added an annotation above all my classes and in the OnModelBuilding specifying its schema. I still get the same error.

    The only time it works is if I remove ManagementStudios schema entirely. I'm not sure why this is happening but it seems to be the only workaround for now?

    The main place where this error is happening here at the sign in process:

    var claimsPrincipal = await _signInManager.CreateUserPrincipalAsync(user);

    For some reason the Claims section keeps asking for a schema-less table. This isn't an issue with ManagementStudio that uses the same method to login but for DocumentStudio which is another application, I get errors.

    Is it possible to use a db schema for Identity items and let other applications reference you?

    I noticed also that I have duplicate tables for similar items named IdentityUserRole and IdentityUserClaim. I have tried to merge them in this question but that just gave me more issues:

    This is how I did it:

    I overrode the IdentityUserRole class

    [Table("IdentityUserRole", Schema = "ManagementStudio")]
    public class UserRoles : IdentityUserRole<string>
        public string Id { get; set; }
        public override string UserId { get; set; }
        public virtual ApplicationUsers Users { get; set; }
        public override string RoleId { get; set; }
        public virtual Roles Roles { get; set; }

    In my DbContext class:

    public DbSet<UserRoles> UserRoles{ get; set; }

    In my onModelBuilding

                .ToTable("IdentityUserRole", schema: "ManagementStudio");

    This is the error I get when I try to login:

    An unhandled exception occurred while processing the request. InvalidOperationException: Cannot create a DbSet for 'IdentityUserRole' because this type is not included in the model for the context. Microsoft.EntityFrameworkCore.Internal.InternalDbSet.get_EntityType()

    This happens for IdentityUserClaim as well.

    Thursday, June 27, 2019 5:33 AM

All replies

  • User-1764593085 posted

    Hi stardocsSVC,

    Have you tried to set default schema like below, remember to place `base.OnModelCreating(modelBuilder);` at the beginning.

    protected override void OnModelCreating(ModelBuilder modelBuilder)

    Best Regards,


    Friday, June 28, 2019 5:04 AM