首先,我不能使用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)