我创建了类DataContect,它是从类IdentityDbContext继承而来的:
using ProjDAL.Entities;
using ProjDAL.Relations;
using ProjDAL.Services;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace ProjDAL.EF
{
public class DataContext : IdentityDbContext<ApplicationUser>
{
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
.......................................................
}
解决方案具有控制台应用程序,我在其中创建新的DataContext:
using System;
using DbInitialize.Interface;
using ProjDAL.EF;
namespace DbInitialize.Provider
{
public class DbInitializeProvider : IDbInitialize
{
private DataContext _db;
public DbInitializeProvider()
{
_db = new DataContext(options => options.UseSqlServer("Data Source=.\\SQLEXPRESS;Initial Catalog=ProjAppTest;Integrated Security=True;MultipleActiveResultSets=true"));
我收到错误:无法将lambda表达式转换为类型“DbContextOptions”,因为它不是委托类型 如何正确创建DataContext实例并设置选项参数?
如果您需要更多信息,请告诉我。感谢您的帮助。
UYOU
相关分类