//參考自以下 //https://www.cnblogs.com/enternal/p/4764741.html //https://www.cnblogs.com/dudu/p/entity-framework-warm-up.html using (var dbContext = new YourDbContext()) { var objectContext = ((IObjectContextAdapter)dbContext).ObjectContext; var mappingCollection = (StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection( DataSpace.CSSpace ); mappingCollection.GenerateViews( new List<EdmSchemaError>() ); }
The DbContext of type 'ApiDbContext' cannot be pooled because it does not have a public constructor accepting a single parameter of type DbContextOptions or has more than one constructor.'