Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
EF核心SqLite内存中没有这样的表?_Sqlite_Asp.net Core_Entity Framework Core_In Memory Database - Fatal编程技术网

EF核心SqLite内存中没有这样的表?

EF核心SqLite内存中没有这样的表?,sqlite,asp.net-core,entity-framework-core,in-memory-database,Sqlite,Asp.net Core,Entity Framework Core,In Memory Database,我使用UseInMemoryDatabase()配置了我的ASP.NET Core 2.2应用程序,效果很好。现在我在内存中将其更改为关系Sqlite Startup.cs services.AddDbContext<ApplicationContext>(options => options.UseSqlite("Datasource=file::memory:?cache=shared")); services.AddDbContext创建并将迁移应用到内存中的SQLi

我使用UseInMemoryDatabase()配置了我的ASP.NET Core 2.2应用程序,效果很好。现在我在内存中将其更改为关系Sqlite

Startup.cs

 services.AddDbContext<ApplicationContext>(options => options.UseSqlite("Datasource=file::memory:?cache=shared"));

services.AddDbContext

创建并将迁移应用到内存中的SQLite数据库。每次应用程序启动时,您都必须应用它们,因为在应用程序退出之前,数据库只存在于内存中。

在ConfigureServices()中的Startup.cs中,我打开了与数据库的连接。在Configure()中,我获取上下文并运行context.Database.Migrate()。仍然是同一个错误,但当我使用context.Database.EnsureCreated()时,它启动时没有错误。因此,迁移不起作用,只需创建db模式即可。