ASP.Net Core - How to add a new field to the default Microsoft Identity structure












0















Using ASP.Net Core 2.1, I am trying to add a new field to the default Microsoft Identity Users table structure, so I created a new model that I used in the project database context to inherit from Microsoft.AspNetCore.Identity, I used to implement the following code successfully but this time I got error.



Here is the model:



public class ApplicationUser : IdentityUser
{
public string Age { get; set; }
}


Here is the database context:



public class ApplicationDbContext : IdentityDbContext<ApplicationUser, string>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
public string CurrentUserId { get; set; }
}


And here is the output error:




The non-generic type 'IdentityDbContext' cannot be used with type arguments




What am I doing wrong here ?










share|improve this question





























    0















    Using ASP.Net Core 2.1, I am trying to add a new field to the default Microsoft Identity Users table structure, so I created a new model that I used in the project database context to inherit from Microsoft.AspNetCore.Identity, I used to implement the following code successfully but this time I got error.



    Here is the model:



    public class ApplicationUser : IdentityUser
    {
    public string Age { get; set; }
    }


    Here is the database context:



    public class ApplicationDbContext : IdentityDbContext<ApplicationUser, string>
    {
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
    public string CurrentUserId { get; set; }
    }


    And here is the output error:




    The non-generic type 'IdentityDbContext' cannot be used with type arguments




    What am I doing wrong here ?










    share|improve this question



























      0












      0








      0








      Using ASP.Net Core 2.1, I am trying to add a new field to the default Microsoft Identity Users table structure, so I created a new model that I used in the project database context to inherit from Microsoft.AspNetCore.Identity, I used to implement the following code successfully but this time I got error.



      Here is the model:



      public class ApplicationUser : IdentityUser
      {
      public string Age { get; set; }
      }


      Here is the database context:



      public class ApplicationDbContext : IdentityDbContext<ApplicationUser, string>
      {
      public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
      public string CurrentUserId { get; set; }
      }


      And here is the output error:




      The non-generic type 'IdentityDbContext' cannot be used with type arguments




      What am I doing wrong here ?










      share|improve this question
















      Using ASP.Net Core 2.1, I am trying to add a new field to the default Microsoft Identity Users table structure, so I created a new model that I used in the project database context to inherit from Microsoft.AspNetCore.Identity, I used to implement the following code successfully but this time I got error.



      Here is the model:



      public class ApplicationUser : IdentityUser
      {
      public string Age { get; set; }
      }


      Here is the database context:



      public class ApplicationDbContext : IdentityDbContext<ApplicationUser, string>
      {
      public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
      public string CurrentUserId { get; set; }
      }


      And here is the output error:




      The non-generic type 'IdentityDbContext' cannot be used with type arguments




      What am I doing wrong here ?







      c# asp.net-core asp.net-identity






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 12:37







      Sami-L

















      asked Nov 26 '18 at 12:30









      Sami-LSami-L

      2,11894062




      2,11894062
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I am not sure, but I don't see a base constructor which accepts those 2 type arguments.



          See MSDN



          Valid type arguments are:



          //none
          public class IdentityDbContext


          or



          //application user
          public class IdentityDbContext<TUser>


          or



          //Thanks to @ Ivvan
          public class IdentityDbContext<TUser,TRole,TKey>


          or



          //the full version
          public class IdentityDbContext<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim>




          So in your case, I think you meant:



          public class ApplicationDbContext : IdentityDbContext<ApplicationUser>





          share|improve this answer





















          • 1





            It is true for EF6, but there is extra constructor in EF Core, that accept 3 params: TUser, TRole, TKey. But anyway, OP missed one parameter.

            – Ivvan
            Nov 26 '18 at 12:46













          • @Ivvan: thanks for the heads-up... I was lost in the Forrest of docs.

            – Stefan
            Nov 26 '18 at 12:51






          • 1





            @Ivvan, just for information, Previously I was using it with 3 params: TUser, TRole, TKey, currently I need only one param, TUser and now it works perfect after I removed the missing Tkey (string).

            – Sami-L
            Nov 26 '18 at 13:05






          • 1





            @Stefan, Yes, you're right, it was just a stupid error, I copied the code with 3 params and missed to remove the third one: "string", as I don't need roles in my project, now it works fine using: public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

            – Sami-L
            Nov 26 '18 at 13:10












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53481182%2fasp-net-core-how-to-add-a-new-field-to-the-default-microsoft-identity-structur%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I am not sure, but I don't see a base constructor which accepts those 2 type arguments.



          See MSDN



          Valid type arguments are:



          //none
          public class IdentityDbContext


          or



          //application user
          public class IdentityDbContext<TUser>


          or



          //Thanks to @ Ivvan
          public class IdentityDbContext<TUser,TRole,TKey>


          or



          //the full version
          public class IdentityDbContext<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim>




          So in your case, I think you meant:



          public class ApplicationDbContext : IdentityDbContext<ApplicationUser>





          share|improve this answer





















          • 1





            It is true for EF6, but there is extra constructor in EF Core, that accept 3 params: TUser, TRole, TKey. But anyway, OP missed one parameter.

            – Ivvan
            Nov 26 '18 at 12:46













          • @Ivvan: thanks for the heads-up... I was lost in the Forrest of docs.

            – Stefan
            Nov 26 '18 at 12:51






          • 1





            @Ivvan, just for information, Previously I was using it with 3 params: TUser, TRole, TKey, currently I need only one param, TUser and now it works perfect after I removed the missing Tkey (string).

            – Sami-L
            Nov 26 '18 at 13:05






          • 1





            @Stefan, Yes, you're right, it was just a stupid error, I copied the code with 3 params and missed to remove the third one: "string", as I don't need roles in my project, now it works fine using: public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

            – Sami-L
            Nov 26 '18 at 13:10
















          1














          I am not sure, but I don't see a base constructor which accepts those 2 type arguments.



          See MSDN



          Valid type arguments are:



          //none
          public class IdentityDbContext


          or



          //application user
          public class IdentityDbContext<TUser>


          or



          //Thanks to @ Ivvan
          public class IdentityDbContext<TUser,TRole,TKey>


          or



          //the full version
          public class IdentityDbContext<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim>




          So in your case, I think you meant:



          public class ApplicationDbContext : IdentityDbContext<ApplicationUser>





          share|improve this answer





















          • 1





            It is true for EF6, but there is extra constructor in EF Core, that accept 3 params: TUser, TRole, TKey. But anyway, OP missed one parameter.

            – Ivvan
            Nov 26 '18 at 12:46













          • @Ivvan: thanks for the heads-up... I was lost in the Forrest of docs.

            – Stefan
            Nov 26 '18 at 12:51






          • 1





            @Ivvan, just for information, Previously I was using it with 3 params: TUser, TRole, TKey, currently I need only one param, TUser and now it works perfect after I removed the missing Tkey (string).

            – Sami-L
            Nov 26 '18 at 13:05






          • 1





            @Stefan, Yes, you're right, it was just a stupid error, I copied the code with 3 params and missed to remove the third one: "string", as I don't need roles in my project, now it works fine using: public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

            – Sami-L
            Nov 26 '18 at 13:10














          1












          1








          1







          I am not sure, but I don't see a base constructor which accepts those 2 type arguments.



          See MSDN



          Valid type arguments are:



          //none
          public class IdentityDbContext


          or



          //application user
          public class IdentityDbContext<TUser>


          or



          //Thanks to @ Ivvan
          public class IdentityDbContext<TUser,TRole,TKey>


          or



          //the full version
          public class IdentityDbContext<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim>




          So in your case, I think you meant:



          public class ApplicationDbContext : IdentityDbContext<ApplicationUser>





          share|improve this answer















          I am not sure, but I don't see a base constructor which accepts those 2 type arguments.



          See MSDN



          Valid type arguments are:



          //none
          public class IdentityDbContext


          or



          //application user
          public class IdentityDbContext<TUser>


          or



          //Thanks to @ Ivvan
          public class IdentityDbContext<TUser,TRole,TKey>


          or



          //the full version
          public class IdentityDbContext<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim>




          So in your case, I think you meant:



          public class ApplicationDbContext : IdentityDbContext<ApplicationUser>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 26 '18 at 12:50

























          answered Nov 26 '18 at 12:39









          StefanStefan

          8,55173862




          8,55173862








          • 1





            It is true for EF6, but there is extra constructor in EF Core, that accept 3 params: TUser, TRole, TKey. But anyway, OP missed one parameter.

            – Ivvan
            Nov 26 '18 at 12:46













          • @Ivvan: thanks for the heads-up... I was lost in the Forrest of docs.

            – Stefan
            Nov 26 '18 at 12:51






          • 1





            @Ivvan, just for information, Previously I was using it with 3 params: TUser, TRole, TKey, currently I need only one param, TUser and now it works perfect after I removed the missing Tkey (string).

            – Sami-L
            Nov 26 '18 at 13:05






          • 1





            @Stefan, Yes, you're right, it was just a stupid error, I copied the code with 3 params and missed to remove the third one: "string", as I don't need roles in my project, now it works fine using: public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

            – Sami-L
            Nov 26 '18 at 13:10














          • 1





            It is true for EF6, but there is extra constructor in EF Core, that accept 3 params: TUser, TRole, TKey. But anyway, OP missed one parameter.

            – Ivvan
            Nov 26 '18 at 12:46













          • @Ivvan: thanks for the heads-up... I was lost in the Forrest of docs.

            – Stefan
            Nov 26 '18 at 12:51






          • 1





            @Ivvan, just for information, Previously I was using it with 3 params: TUser, TRole, TKey, currently I need only one param, TUser and now it works perfect after I removed the missing Tkey (string).

            – Sami-L
            Nov 26 '18 at 13:05






          • 1





            @Stefan, Yes, you're right, it was just a stupid error, I copied the code with 3 params and missed to remove the third one: "string", as I don't need roles in my project, now it works fine using: public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

            – Sami-L
            Nov 26 '18 at 13:10








          1




          1





          It is true for EF6, but there is extra constructor in EF Core, that accept 3 params: TUser, TRole, TKey. But anyway, OP missed one parameter.

          – Ivvan
          Nov 26 '18 at 12:46







          It is true for EF6, but there is extra constructor in EF Core, that accept 3 params: TUser, TRole, TKey. But anyway, OP missed one parameter.

          – Ivvan
          Nov 26 '18 at 12:46















          @Ivvan: thanks for the heads-up... I was lost in the Forrest of docs.

          – Stefan
          Nov 26 '18 at 12:51





          @Ivvan: thanks for the heads-up... I was lost in the Forrest of docs.

          – Stefan
          Nov 26 '18 at 12:51




          1




          1





          @Ivvan, just for information, Previously I was using it with 3 params: TUser, TRole, TKey, currently I need only one param, TUser and now it works perfect after I removed the missing Tkey (string).

          – Sami-L
          Nov 26 '18 at 13:05





          @Ivvan, just for information, Previously I was using it with 3 params: TUser, TRole, TKey, currently I need only one param, TUser and now it works perfect after I removed the missing Tkey (string).

          – Sami-L
          Nov 26 '18 at 13:05




          1




          1





          @Stefan, Yes, you're right, it was just a stupid error, I copied the code with 3 params and missed to remove the third one: "string", as I don't need roles in my project, now it works fine using: public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

          – Sami-L
          Nov 26 '18 at 13:10





          @Stefan, Yes, you're right, it was just a stupid error, I copied the code with 3 params and missed to remove the third one: "string", as I don't need roles in my project, now it works fine using: public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

          – Sami-L
          Nov 26 '18 at 13:10




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53481182%2fasp-net-core-how-to-add-a-new-field-to-the-default-microsoft-identity-structur%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Create new schema in PostgreSQL using DBeaver

          Deepest pit of an array with Javascript: test on Codility

          Fotorealismo