Example #1
0
        public CodeAFriendContext NewContext()
        {
            var context = new CodeAFriendContext(Options);

            _contexts.Add(context);
            return(context);
        }
Example #2
0
        public InMemoryCodeAFriendDatabase(bool ensureSchema = true)
        {
            Connection.Open();
            Options = new DbContextOptionsBuilder <CodeAFriendContext>().UseSqlite(Connection).Options;

            // Create the schema in the database
            if (ensureSchema)
            {
                using (var context = new CodeAFriendContext(Options))
                {
                    context.Database.EnsureCreated();
                }
            }
        }