【发布时间】:2021-11-18 16:12:57
【问题描述】:
尝试学习 C# 时遇到以下错误:
CS1503: Argument 1: cannot convert from
'BookAPI.Models.DbContextOPtions<BookAPI.Models.BookContext>'
to 'Microsoft.EntityFrameworkCore.DbContextOptions'
我只是按照这里的教程进行操作:https://www.youtube.com/watch?v=sWJayOop4k8
我正在创建名为 BookContext.cs 的文件。截至目前,代码如下所示:
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BookAPI.Models
{
public class BookContext : DbContext
{
public BookContext(DbContextOPtions<BookContext> options)
:base(options) // <-- error is pointing here
{
Database.EnsureCreated();
}
}
}
我在 Mac 上使用 Visual Studio 2019 免费版。
我缺少什么以及如何解决?
【问题讨论】:
标签: c# .net entity-framework .net-core entity-framework-core