コード例 #1
0
ファイル: PersonTests.cs プロジェクト: owenlacey/EfTest
        public void Setup()
        {
            //Create an in-memory DbConnection https://entityframework-effort.net/
            var dbConnection = Effort.DbConnectionFactory.CreateTransient();

            this._context = new SandwichContext(dbConnection);
        }
コード例 #2
0
        public void Setup()
        {
            //https://garywoodfine.com/entity-framework-core-memory-testing-database/
            var connection = new SqliteConnection("DataSource=:memory:");
            var dbOptions  = new DbContextOptionsBuilder <SandwichContext>()
                             .UseSqlite(connection)
                             .Options;

            _context = new SandwichContext(dbOptions);
            _context.Database.OpenConnection();
            _context.Database.EnsureCreated();
        }