using Microsoft.EntityFrameworkCore; using MongoDB.Driver; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BookStore { public class BookStoreContext : DbContext { private IMongoDatabase _db { get; set; } private MongoClient _mongoClient { get; set; } public BookStoreContext() { _mongoClient = new MongoClient(ConfigurationManager.ConnectionStrings["BookStore"].ConnectionString); _db = _mongoClient.GetDatabase(ConfigurationManager.ConnectionStrings["BookStore"].Name); } public IMongoCollection GetCollection(string nameCollection) { return _db.GetCollection(nameCollection); } } }