Why DbSet not works with asp.net core web application?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm working on an ASP.Net Core Web Application. While trying to set the dbset<>, I get this error.
This line of code gives error:
public DbSet<Person> Persons { get; set; }
Resharper suggests two options:




  • System.Data.Entity.

  • Microsoft.EntityFrameworkCore.


public System.Data.Entity.DbSet<Person> Persons { get; set; }



Can anyone please explain which one to chose: the first or second option?



I have included the necessary references.



using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using Microsoft.EntityFrameworkCore;
using DbContext = System.Data.Entity.DbContext;


I see this error: enter image description here










share|improve this question































    0















    I'm working on an ASP.Net Core Web Application. While trying to set the dbset<>, I get this error.
    This line of code gives error:
    public DbSet<Person> Persons { get; set; }
    Resharper suggests two options:




    • System.Data.Entity.

    • Microsoft.EntityFrameworkCore.


    public System.Data.Entity.DbSet<Person> Persons { get; set; }



    Can anyone please explain which one to chose: the first or second option?



    I have included the necessary references.



    using System.Data.Entity;
    using System.Data.Entity.ModelConfiguration.Conventions;
    using Microsoft.EntityFrameworkCore;
    using DbContext = System.Data.Entity.DbContext;


    I see this error: enter image description here










    share|improve this question



























      0












      0








      0








      I'm working on an ASP.Net Core Web Application. While trying to set the dbset<>, I get this error.
      This line of code gives error:
      public DbSet<Person> Persons { get; set; }
      Resharper suggests two options:




      • System.Data.Entity.

      • Microsoft.EntityFrameworkCore.


      public System.Data.Entity.DbSet<Person> Persons { get; set; }



      Can anyone please explain which one to chose: the first or second option?



      I have included the necessary references.



      using System.Data.Entity;
      using System.Data.Entity.ModelConfiguration.Conventions;
      using Microsoft.EntityFrameworkCore;
      using DbContext = System.Data.Entity.DbContext;


      I see this error: enter image description here










      share|improve this question
















      I'm working on an ASP.Net Core Web Application. While trying to set the dbset<>, I get this error.
      This line of code gives error:
      public DbSet<Person> Persons { get; set; }
      Resharper suggests two options:




      • System.Data.Entity.

      • Microsoft.EntityFrameworkCore.


      public System.Data.Entity.DbSet<Person> Persons { get; set; }



      Can anyone please explain which one to chose: the first or second option?



      I have included the necessary references.



      using System.Data.Entity;
      using System.Data.Entity.ModelConfiguration.Conventions;
      using Microsoft.EntityFrameworkCore;
      using DbContext = System.Data.Entity.DbContext;


      I see this error: enter image description here







      asp.net asp.net-core






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 20:32







      user10489212

















      asked Nov 26 '18 at 20:26









      user10489212user10489212

      637




      637
























          2 Answers
          2






          active

          oldest

          votes


















          4














          The using directive is a shortcut to allow you to write just DbSet instead of System.Data.Entity.DbSet, for example.



          But both System.Data.Entity and Microsoft.EntityFrameworkCore have a DbSet class, so it doesn't know which one to use, and it's not going to choose for you. So you have to tell it.



          That said, you shouldn't be using both. Entity Framework 6 and Entity Framework Core are two completely different things. System.Data.Entity is for EF 6, and Microsoft.EntityFrameworkCore is for EF Core.



          You probably shouldn't be using System.Data.Entity.






          share|improve this answer


























          • Thanks guys. Now that I only use Microsoft.EntityFrameworkcore, this method starts complaining: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }

            – user10489212
            Nov 26 '18 at 20:40






          • 1





            Your declaration is wrong. Look at the example OnModelCreating method here: docs.microsoft.com/en-us/ef/core/modeling

            – Gabriel Luci
            Nov 26 '18 at 20:41



















          1














          The reason is Ambigous Reference:
          that DbSet<> is defined in both System.Data.Entity and Microsoft.EntityFrameworkCore.



          Since you are working with ASPNET Core, recommended is to use Microsoft.EntityFrameworkCore






          share|improve this answer
























            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%2f53488520%2fwhy-dbset-not-works-with-asp-net-core-web-application%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            The using directive is a shortcut to allow you to write just DbSet instead of System.Data.Entity.DbSet, for example.



            But both System.Data.Entity and Microsoft.EntityFrameworkCore have a DbSet class, so it doesn't know which one to use, and it's not going to choose for you. So you have to tell it.



            That said, you shouldn't be using both. Entity Framework 6 and Entity Framework Core are two completely different things. System.Data.Entity is for EF 6, and Microsoft.EntityFrameworkCore is for EF Core.



            You probably shouldn't be using System.Data.Entity.






            share|improve this answer


























            • Thanks guys. Now that I only use Microsoft.EntityFrameworkcore, this method starts complaining: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }

              – user10489212
              Nov 26 '18 at 20:40






            • 1





              Your declaration is wrong. Look at the example OnModelCreating method here: docs.microsoft.com/en-us/ef/core/modeling

              – Gabriel Luci
              Nov 26 '18 at 20:41
















            4














            The using directive is a shortcut to allow you to write just DbSet instead of System.Data.Entity.DbSet, for example.



            But both System.Data.Entity and Microsoft.EntityFrameworkCore have a DbSet class, so it doesn't know which one to use, and it's not going to choose for you. So you have to tell it.



            That said, you shouldn't be using both. Entity Framework 6 and Entity Framework Core are two completely different things. System.Data.Entity is for EF 6, and Microsoft.EntityFrameworkCore is for EF Core.



            You probably shouldn't be using System.Data.Entity.






            share|improve this answer


























            • Thanks guys. Now that I only use Microsoft.EntityFrameworkcore, this method starts complaining: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }

              – user10489212
              Nov 26 '18 at 20:40






            • 1





              Your declaration is wrong. Look at the example OnModelCreating method here: docs.microsoft.com/en-us/ef/core/modeling

              – Gabriel Luci
              Nov 26 '18 at 20:41














            4












            4








            4







            The using directive is a shortcut to allow you to write just DbSet instead of System.Data.Entity.DbSet, for example.



            But both System.Data.Entity and Microsoft.EntityFrameworkCore have a DbSet class, so it doesn't know which one to use, and it's not going to choose for you. So you have to tell it.



            That said, you shouldn't be using both. Entity Framework 6 and Entity Framework Core are two completely different things. System.Data.Entity is for EF 6, and Microsoft.EntityFrameworkCore is for EF Core.



            You probably shouldn't be using System.Data.Entity.






            share|improve this answer















            The using directive is a shortcut to allow you to write just DbSet instead of System.Data.Entity.DbSet, for example.



            But both System.Data.Entity and Microsoft.EntityFrameworkCore have a DbSet class, so it doesn't know which one to use, and it's not going to choose for you. So you have to tell it.



            That said, you shouldn't be using both. Entity Framework 6 and Entity Framework Core are two completely different things. System.Data.Entity is for EF 6, and Microsoft.EntityFrameworkCore is for EF Core.



            You probably shouldn't be using System.Data.Entity.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 26 '18 at 20:37

























            answered Nov 26 '18 at 20:31









            Gabriel LuciGabriel Luci

            11.6k11525




            11.6k11525













            • Thanks guys. Now that I only use Microsoft.EntityFrameworkcore, this method starts complaining: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }

              – user10489212
              Nov 26 '18 at 20:40






            • 1





              Your declaration is wrong. Look at the example OnModelCreating method here: docs.microsoft.com/en-us/ef/core/modeling

              – Gabriel Luci
              Nov 26 '18 at 20:41



















            • Thanks guys. Now that I only use Microsoft.EntityFrameworkcore, this method starts complaining: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }

              – user10489212
              Nov 26 '18 at 20:40






            • 1





              Your declaration is wrong. Look at the example OnModelCreating method here: docs.microsoft.com/en-us/ef/core/modeling

              – Gabriel Luci
              Nov 26 '18 at 20:41

















            Thanks guys. Now that I only use Microsoft.EntityFrameworkcore, this method starts complaining: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }

            – user10489212
            Nov 26 '18 at 20:40





            Thanks guys. Now that I only use Microsoft.EntityFrameworkcore, this method starts complaining: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); }

            – user10489212
            Nov 26 '18 at 20:40




            1




            1





            Your declaration is wrong. Look at the example OnModelCreating method here: docs.microsoft.com/en-us/ef/core/modeling

            – Gabriel Luci
            Nov 26 '18 at 20:41





            Your declaration is wrong. Look at the example OnModelCreating method here: docs.microsoft.com/en-us/ef/core/modeling

            – Gabriel Luci
            Nov 26 '18 at 20:41













            1














            The reason is Ambigous Reference:
            that DbSet<> is defined in both System.Data.Entity and Microsoft.EntityFrameworkCore.



            Since you are working with ASPNET Core, recommended is to use Microsoft.EntityFrameworkCore






            share|improve this answer




























              1














              The reason is Ambigous Reference:
              that DbSet<> is defined in both System.Data.Entity and Microsoft.EntityFrameworkCore.



              Since you are working with ASPNET Core, recommended is to use Microsoft.EntityFrameworkCore






              share|improve this answer


























                1












                1








                1







                The reason is Ambigous Reference:
                that DbSet<> is defined in both System.Data.Entity and Microsoft.EntityFrameworkCore.



                Since you are working with ASPNET Core, recommended is to use Microsoft.EntityFrameworkCore






                share|improve this answer













                The reason is Ambigous Reference:
                that DbSet<> is defined in both System.Data.Entity and Microsoft.EntityFrameworkCore.



                Since you are working with ASPNET Core, recommended is to use Microsoft.EntityFrameworkCore







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 20:33









                Mohsin MehmoodMohsin Mehmood

                2,6572513




                2,6572513






























                    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%2f53488520%2fwhy-dbset-not-works-with-asp-net-core-web-application%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

                    Tonle Sap (See)

                    I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

                    Guatemaltekische Davis-Cup-Mannschaft