/// <summary>
        /// 工厂方法
        /// </summary>
        /// <returns>数据仓储</returns>
        public static BaseRepository Factory()
        {
            DbContext dbContext = new PermissionEntities();

            // 默认sqlserver仓储 也可以改用mysql仓储
            BaseRepository repository = new SqlRepository(dbContext);

            return(repository);
        }
        /// <summary>
        /// 测试链接数据库.
        /// </summary>
        public static void AddPermission()
        {
            Role r = new Role
            {
                Name     = "sdsd",
                Id       = Guid.NewGuid(),
                Enabled  = true,
                ParentId = Guid.NewGuid(),
                Remark   = "sdsdsd"
            };

            // 一定要引用 EntityFramework跟EntityFramework.SqlServer 这个2个dll
            // 也可以直接使用当前上下文实现(不推荐此方法)
            using (PermissionEntities p = new PermissionEntities())
            {
                p.Roles.Add(r);
                p.SaveChanges();
            }
        }