static void InitDatabase() { using (eShopContext _db = new eShopContext()) { Console.WriteLine(); Console.WriteLine("刪除 - 資料庫"); _db.Database.EnsureDeleted(); Console.WriteLine("新增 - 資料庫"); _db.Database.EnsureCreated(); Console.WriteLine(); Console.WriteLine("資料庫初始化完成 !"); Console.WriteLine(); ProductMain _productMain; _productMain = new ProductMain(); _productMain.Schema = "DYAJ93A900930IK"; _productMain.Name = "Microsoft Surface Pro (Core i7/16G/256G/W10P)"; _productMain.SellPrice = 70888; _productMain.ProductStorage = new ProductStorage() { Storage = 75 }; _db.ProductMains.Add(_productMain); _productMain = new ProductMain(); _productMain.Schema = "DYAJ93A900929IK"; _productMain.Name = "Microsoft Surface Pro (Core i5/8G/128G/W10P)"; _productMain.SellPrice = 51888; _productMain.ProductStorage = new ProductStorage() { Storage = 75 }; _db.ProductMains.Add(_productMain); _productMain = new ProductMain(); _productMain.Schema = "DYAJ93A900928IK"; _productMain.Name = "Microsoft Surface Pro (Core i3/4G/128G/W10P)"; _productMain.SellPrice = 41888; _productMain.ProductStorage = new ProductStorage() { Storage = 75 }; _db.ProductMains.Add(_productMain); _db.SaveChanges(); Console.WriteLine("資料內容初始化完成 !"); Console.WriteLine(); } }
public EventLogRepository(eShopContext context) { _context = context; }
public ProductRepository(eShopContext context) { _context = context; }
public UnitOfWork() { this._context = new eShopContext(); }
public OrderRepository(eShopContext context) { _context = context; }