[英]Can't find ApplicationDbContext in DbContextOptions
我是 .net 框架的新手,我堅持使用這個 ApplicationDbContext,這是我的代碼示例:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace Rocky.Data
{
public class ProjectDbContext:DbContext
{
public ProjectDbContext(DbContextOptions<ApplicationDbContext> options): base(options)
{
}
}
}
您的問題是 ApplicationDbContext 不是模塊,它是承包商的類名。 所以用 ProjectDbContext 替換 ApplicationDbContext。 你的問題得到解決。
這是您的代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace Rocky.Data
{
public class ProjectDbContext:DbContext
{
public ProjectDbContext(DbContextOptions<ProjectDbContext> options): base(options)
{
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.