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;
}
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: 
asp.net asp.net-core
add a comment |
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: 
asp.net asp.net-core
add a comment |
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: 
asp.net asp.net-core
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: 
asp.net asp.net-core
asp.net asp.net-core
edited Nov 26 '18 at 20:32
user10489212
asked Nov 26 '18 at 20:26
user10489212user10489212
637
637
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
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 exampleOnModelCreatingmethod here: docs.microsoft.com/en-us/ef/core/modeling
– Gabriel Luci
Nov 26 '18 at 20:41
add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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 exampleOnModelCreatingmethod here: docs.microsoft.com/en-us/ef/core/modeling
– Gabriel Luci
Nov 26 '18 at 20:41
add a comment |
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.
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 exampleOnModelCreatingmethod here: docs.microsoft.com/en-us/ef/core/modeling
– Gabriel Luci
Nov 26 '18 at 20:41
add a comment |
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.
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.
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 exampleOnModelCreatingmethod here: docs.microsoft.com/en-us/ef/core/modeling
– Gabriel Luci
Nov 26 '18 at 20:41
add a comment |
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 exampleOnModelCreatingmethod 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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Nov 26 '18 at 20:33
Mohsin MehmoodMohsin Mehmood
2,6572513
2,6572513
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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