protected override void Down(MigrationBuilder migrationBuilder) { using (PassengersContext context = new PassengersContext()) { context.Database.ExecuteSqlCommand("TRUNCATE TABLE [TableName]"); } }
public UnitOfWork( PassengersContext context, ILifetimeScope lifetimeScope, IRepositoryFactory repositoryFactory ) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.lifetimeScope = lifetimeScope ?? throw new ArgumentNullException(nameof(lifetimeScope)); this.repositoryFactory = repositoryFactory; }
protected override void Up(MigrationBuilder migrationBuilder) { FileInfo seedFilePath = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "Migrations/DataSeed/titanic.csv")); Console.WriteLine($"Titanic: {seedFilePath}"); using (StreamReader reader = new StreamReader(seedFilePath.FullName, Encoding.ASCII)) using (CsvReader csvReader = new CsvReader(reader)) using (PassengersContext context = new PassengersContext()) { var records = csvReader.GetRecords <Passenger>().ToArray(); context.Passengers.AddRange(records); context.SaveChanges(); } }
public ApplicationUserStore(PassengersContext context) : base(context) { }
public IRepository <T> CreateRepository <T>(PassengersContext context, ILifetimeScope lifetimeScope) { return(lifetimeScope.Resolve <IRepository <T> >(new NamedParameter("context", context))); }
public PassengersController(PassengersContext context) { _context = context; }
public BaseRepository(PassengersContext context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); entities = this.context.Set <T>(); }