public override TransportationContext CreateContext(SqlCeTestStore testStore, Action <ModelBuilder> onModelCreating) { var optionsBuilder = new DbContextOptionsBuilder() .UseSqlCe(testStore.Connection, b => b.ApplyConfiguration().CommandTimeout(300)) .EnableSensitiveDataLogging() .UseInternalServiceProvider(BuildServiceProvider(onModelCreating)); var context = new TransportationContext(optionsBuilder.Options); context.Database.UseTransaction(testStore.Transaction); return(context); }
public override SqliteTestStore CreateTestStore(Action <ModelBuilder> onModelCreating) => SqliteTestStore.GetOrCreateShared(DatabaseName, false, true, () => { var optionsBuilder = new DbContextOptionsBuilder() .UseSqlite(SqliteTestStore.CreateConnectionString(DatabaseName)) .EnableSensitiveDataLogging() .UseInternalServiceProvider(BuildServiceProvider(onModelCreating)); using (var context = new TransportationContext(optionsBuilder.Options)) { context.Database.EnsureClean(); context.Seed(); } });
public override SqlCeTestStore CreateTestStore(Action <ModelBuilder> onModelCreating) => SqlCeTestStore.GetOrCreateShared(DatabaseName, () => { var optionsBuilder = new DbContextOptionsBuilder() .UseSqlCe(_connectionString, b => b.ApplyConfiguration().CommandTimeout(300)) .EnableSensitiveDataLogging() .UseInternalServiceProvider(BuildServiceProvider(onModelCreating)); using (var context = new TransportationContext(optionsBuilder.Options)) { context.Database.EnsureCreated(); context.Seed(); } });
protected virtual void OnModelCreating(ModelBuilder modelBuilder) { TransportationContext.OnModelCreatingBase(modelBuilder); modelBuilder.Entity <Vehicle>(eb => { eb.HasDiscriminator <string>("Discriminator"); eb.Property <string>("Discriminator").HasColumnName("Discriminator"); eb.ToTable("Vehicles"); }); modelBuilder.Entity <Engine>().ToTable("Vehicles"); modelBuilder.Entity <Operator>().ToTable("Vehicles"); modelBuilder.Entity <FuelTank>().ToTable("Vehicles"); }
/// <summary> /// The constructor accepts a database context instance and initializes the entity set variable /// </summary> /// <param name="context"></param> public GenericRepository(TransportationContext context) { this.context = context; this.dbSet = context.Set <TEntity>(); }
public ComposicaoVagaoRepository(TransportationContext context) : base(context) { }
public UnitOfWork(TransportationContext context) { _context = context; _disposed = false; }
public TremRepository(TransportationContext context) : base(context) { }
public SerieVagaoRepository(TransportationContext context) : base(context) { }
public Repository(TransportationContext context) { Db = context; DbSet = Db.Set <TEntity>(); }
public FerroviaRepository(TransportationContext context) : base(context) { }