小编Yus*_*Cum的帖子

为什么我不能在DbContextOptionsBuilder上调用UseInMemoryDatabase方法?

首先,我不能使用SQL Lite.其次,下面的代码给了我:

Error   CS1061  'DbContextOptionsBuilder<ProductContext>' does not contain a definition for 'UseInMemoryDatabase' and no extension method 'UseInMemoryDatabase' accepting a first argument of type 'DbContextOptionsBuilder<ProductContext>' could be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

代码:

 var options = new DbContextOptionsBuilder<ProductContext>().UseInMemoryDatabase                                  (Guid.NewGuid().ToString())
                              .Options;
            var context = new ProductContext(options);
Run Code Online (Sandbox Code Playgroud)

上下文

using Memory.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace Memory.Data
{
    public class ProductContext : DbContext
    {
        public ProductContext(DbContextOptions<ProductContext> options) : base(options)
        {

        }
        public …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-mvc-4

20
推荐指数
4
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-4 ×1