public Form_Request_TransactionAuxiliary() { InitializeComponent(); var connection = My.ConnectionFactory();//DbConnectionFactory.CreateTransient(); var addToDbSet = false; // TEST using (var db = new EntityContext(connection)) { var d = new Transaction(); db.Transactions.Add(d); d.TransactionAuxiliary = new TransactionAuxiliary { Transaction = d }; if (addToDbSet) { db.TransactionAuxiliaries.Add(d.TransactionAuxiliary); } db.SaveChanges(); if (d.TransactionAuxiliary == null) { throw new Exception("Fails if addToDbSet"); } db.SaveChanges(); if (d.TransactionAuxiliary == null) { throw new Exception("Fails if !addToDbSet"); } } }
public Form_Request_CacheDataLoader() { InitializeComponent(); //using (var context = new EntityContext(My.ConnectionFactory())) //{ // context.EntitySimples.Add(new EntitySimple() { ColumnInt = 2}); // context.SaveChanges(); //} Effort.EntityFrameworkEffortManager.ContextFactory = context => new EntityContext(My.ConnectionFactory()); var actualDataLoader = new Effort.DataLoaders.EntityDataLoader(); var cachedDataLoader = new Effort.DataLoaders.CachingDataLoader(actualDataLoader); var conn = Effort.DbConnectionFactory.CreateTransient(cachedDataLoader); // CLEAN using (var context = new EntityContext(conn)) { var list = context.EntitySimples.ToList(); } //// SEED //using (var context = new EntityContext(connection)) //{ // context.EntitySimples.Add(new EntitySimple { ColumnInt = 1 }); // context.EntitySimples.Add(new EntitySimple { ColumnInt = 2 }); // context.EntitySimples.Add(new EntitySimple { ColumnInt = 3 }); // context.SaveChanges(); //} //// TEST //using (var context = new EntityContext(connection)) //{ //} }