admin管理员组文章数量:1123234
Code:
public class RepositoryContext : DbContext
{
public RepositoryContext(DbContextOptions options)
: base(options)
{
}
}
error:
The type or namespace name 'DbContextOptions' could not be found (are you missing a using directive or an assembly reference?)
Repository D:\My Work\Algos\Repository\RepositoryContext.cs
I am trying to create a DbContext
class here. Is there any issue?
What is missing here? Do I need some namespaces also?
I am getting this error for the first time.
Code:
public class RepositoryContext : DbContext
{
public RepositoryContext(DbContextOptions options)
: base(options)
{
}
}
error:
The type or namespace name 'DbContextOptions' could not be found (are you missing a using directive or an assembly reference?)
Repository D:\My Work\Algos\Repository\RepositoryContext.cs
I am trying to create a DbContext
class here. Is there any issue?
What is missing here? Do I need some namespaces also?
I am getting this error for the first time.
Share Improve this question edited 5 hours ago James Z 12.3k10 gold badges27 silver badges47 bronze badges asked 9 hours ago sampath ssampath s 151 silver badge7 bronze badges 13 | Show 8 more comments1 Answer
Reset to default 2You referenced EntityFramework instead of EntityFrameworkCore.
You need this package: https://www.nuget.org/packages/Microsoft.EntityFrameworkCore
And this namespace: using Microsoft.EntityFrameworkCore;
本文标签: DbContextOptions error in ASPNET Core Web API solutionStack Overflow
版权声明:本文标题:DbContextOptions error in ASP.NET Core Web API solution - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736556879a1944591.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
public RepositoryContext(DbContextOptions<RepositoryContext> options) : base(options) {}
– Bryan Dellinger Commented 8 hours agousing
statements on top of the context file? Is there any chance that you are using EF 6 instead of EF Core? – Guru Stron Commented 8 hours agoare you missing a using directive
have you added the correct using statement? Have you tried right clicking on the error and selecting a fix? Images don't help at all. You need to provide enough code to reproduce the problem and the full error text. Needless to say, EF Core works fine in all ASP.NET Core applications – Panagiotis Kanavos Commented 8 hours agousing
s.//using Microsoft.EntityFrameworkCore;
is a comment andusing System.Data.Entity;
is the old EF namespace. It's not used at all in EF Core – Panagiotis Kanavos Commented 8 hours ago