Multi-Context InMemory Database
问题 Is it possible to have an InMemory database (ASP.NET Core) that is shared across multiple DbContexts? It seems that each DbContext type keeps its own database, even when the same database name is specified in UseInMemoryDatabase. 回答1: The same name is enough. If your instances of DbContext do not 'see' the same in memory DB, it seems they use ones with different names. Make sure your DbContext is created once for the same name. EF Core 2.0 even re-uses in memory databases with the same name: