ThinkPHP 数据库操作之数据表模型和基础模型 ( Model

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

一、定义数据表模型

1.模型映射

要测试数据库是否正常连接,最直接的办法就是在当前控制器中实例化数据表,然后使用 dump 函数输出,查看数据库的链接状态。代码:

public function testdb(){

    $obj=M("User");
    dump($obj);
}

此时浏览器输出:

复制代码

object(Model)#5 (20) {
["_extModel:private"] => NULL
["db:protected"] => object(DbMysql)#7 (18) {
["dbType:protected"] => string(5) "MYSQL"
["autoFree:protected"] => bool(false)
["model:protected"] => string(7) "_think_"
["pconnect:protected"] => bool(false)
["queryStr:protected"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
["modelSql:protected"] => array(1) {
["user"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
}
["lastInsID:protected"] => NULL
["numRows:protected"] => int(2)
["numCols:protected"] => int(0)
["transTimes:protected"] => int(0)
["error:protected"] => string(0) ""
["linkID:protected"] => array(1) {
[0] => resource(27) of type (mysql link)
}
["_linkID:protected"] => resource(27) of type (mysql link)
["queryID:protected"] => resource(28) of type (mysql result)
["connected:protected"] => bool(true)
["comparison:protected"] => array(10) {
["eq"] => string(1) "="
["neq"] => string(2) "<>"
["gt"] => string(1) ">"
["egt"] => string(2) ">="
["lt"] => string(1) "<"
["elt"] => string(2) "<="
["notlike"] => string(8) "NOT LIKE"
["like"] => string(4) "LIKE"
["in"] => string(2) "IN"
["notin"] => string(6) "NOT IN"
}
["selectSql:protected"] => string(96) "SELECT%DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%COMMENT%"
["bind:protected"] => array(0) {
}
}
["pk:protected"] => string(2) "id"
["tablePrefix:protected"] => string(4) "tpk_"
["name:protected"] => string(4) "user"
["dbName:protected"] => string(0) ""
["connection:protected"] => string(0) ""
["tableName:protected"] => string(0) ""
["trueTableName:protected"] => string(8) "tpk_user"
["error:protected"] => string(0) ""
["fields:protected"] => array(5) {
[0] => string(2) "id"
[1] => string(8) "username"
["_autoinc"] => bool(true)
["_pk"] => string(2) "id"
["_type"] => array(2) {
["id"] => string(7) "int(11)"
["username"] => string(11) "varchar(20)"
}
}
["data:protected"] => array(0) {
}
["options:protected"] => array(0) {
}
["_validate:protected"] => array(0) {
}
["_auto:protected"] => array(0) {
}
["_map:protected"] => array(0) {
}
["_scope:protected"] => array(0) {
}
["autoCheckFields:protected"] => bool(true)
["patchValidate:protected"] => bool(false)
["methods:protected"] => array(13) {
[0] => string(5) "table"
[1] => string(5) "order"
[2] => string(5) "alias"
[3] => string(6) "having"
[4] => string(5) "group"
[5] => string(4) "lock"
[6] => string(8) "distinct"
[7] => string(4) "auto"
[8] => string(6) "filter"
[9] => string(8) "validate"
[10] => string(6) "result"
[11] => string(4) "bind"
[12] => string(5) "token"
}
}

http://127.0.0.26/index.php/index/testdb

复制代码
object(Model)#5 (20) {
  ["_extModel:private"] => NULL
  ["db:protected"] => object(DbMysql)#7 (18) {
    ["dbType:protected"] => string(5) "MYSQL"
    ["autoFree:protected"] => bool(false)
    ["model:protected"] => string(7) "_think_"
    ["pconnect:protected"] => bool(false)
    ["queryStr:protected"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
    ["modelSql:protected"] => array(1) {
      ["user"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
    }
    ["lastInsID:protected"] => NULL
    ["numRows:protected"] => int(2)
    ["numCols:protected"] => int(0)
    ["transTimes:protected"] => int(0)
    ["error:protected"] => string(0) ""
    ["linkID:protected"] => array(1) {
      [0] => resource(27) of type (mysql link)
    }
    ["_linkID:protected"] => resource(27) of type (mysql link)
    ["queryID:protected"] => resource(28) of type (mysql result)
    ["connected:protected"] => bool(true)
    ["comparison:protected"] => array(10) {
      ["eq"] => string(1) "="
      ["neq"] => string(2) "<>"
      ["gt"] => string(1) ">"
      ["egt"] => string(2) ">="
      ["lt"] => string(1) "<"
      ["elt"] => string(2) "<="
      ["notlike"] => string(8) "NOT LIKE"
      ["like"] => string(4) "LIKE"
      ["in"] => string(2) "IN"
      ["notin"] => string(6) "NOT IN"
    }
    ["selectSql:protected"] => string(96) "SELECT%DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%COMMENT%"
    ["bind:protected"] => array(0) {
    }
  }
  ["pk:protected"] => string(2) "id"
  ["tablePrefix:protected"] => string(4) "tpk_"
  ["name:protected"] => string(4) "user"
  ["dbName:protected"] => string(0) ""
  ["connection:protected"] => string(0) ""
  ["tableName:protected"] => string(0) ""
  ["trueTableName:protected"] => string(8) "tpk_user"
  ["error:protected"] => string(0) ""
  ["fields:protected"] => array(5) {
    [0] => string(2) "id"
    [1] => string(8) "username"
    ["_autoinc"] => bool(true)
    ["_pk"] => string(2) "id"
    ["_type"] => array(2) {
      ["id"] => string(7) "int(11)"
      ["username"] => string(11) "varchar(20)"
    }
  }
  ["data:protected"] => array(0) {
  }
  ["options:protected"] => array(0) {
  }
  ["_validate:protected"] => array(0) {
  }
  ["_auto:protected"] => array(0) {
  }
  ["_map:protected"] => array(0) {
  }
  ["_scope:protected"] => array(0) {
  }
  ["autoCheckFields:protected"] => bool(true)
  ["patchValidate:protected"] => bool(false)
  ["methods:protected"] => array(13) {
    [0] => string(5) "table"
    [1] => string(5) "order"
    [2] => string(5) "alias"
    [3] => string(6) "having"
    [4] => string(5) "group"
    [5] => string(4) "lock"
    [6] => string(8) "distinct"
    [7] => string(4) "auto"
    [8] => string(6) "filter"
    [9] => string(8) "validate"
    [10] => string(6) "result"
    [11] => string(4) "bind"
    [12] => string(5) "token"
  }
}
复制代码
复制代码

如果没有提示错误即为成功。

M("User") 就是模型映射,M 函数等于 new Model() ,Model 类是模型的基类,也是数据库操作的基类, "User" 是该类的一个成员属性,表示模型名称,模型名称与数据库中的数据表进行映射。注意:User "U" 要大写,数据库中此时应该存在一张 user 表,系统会根据配置文件中的设置给 user 表添加前缀,例如 tpk_user。如果不需要为表添加前缀,将模型名称首字母改为小写,例如 M("user")。

 

2.自定义模型

D 函数用于快速实例化自定义模型,可以进行复杂的数据库操作,比如数据检验、数据缓存、数据加工等。自定义模型存放在 Lib/Model 目录下,例如为数据表 tpk_article 数据表建立模型映射,则需要创建 ArticleModel.class.php,然后使用 D 函数进行实例化,ArticleModel 模型将与 tpk_article 表进行映射。

例:使用 select() 输出 tpk_article 表的数据 ( select() 方法用于列出所有符合条件的数据 ) :

复制代码
复制代码
class IndexAction extends Action {    
    public function article(){

    $obj=D("Article");
    $rows=$obj->select();        
        dump($rows);
   }
}
复制代码
复制代码

浏览器输出:

复制代码

array(6) {
[0] => array(7) {
["id"] => string(1) "1"
["title"] => string(4) "test"
["content"] => string(12) "test_content"
["category"] => string(13) "test_category"
["area"] => string(6) "北京"
["add_user"] => string(5) "admin"
["add_time"] => string(19) "2014-11-20 23:03:44"
}
[1] => array(7) {
["id"] => string(1) "2"
["title"] => string(12) "吼吼吼吼"
["content"] => string(18) "任溶溶柔然人"
["category"] => string(14) "test_category2"
["area"] => string(6) "河北"
["add_user"] => string(5) "admin"
["add_time"] => string(19) "2014-11-22 15:16:12"
}
[2] => array(7) {
["id"] => string(1) "4"
["title"] => string(7) "test2_m"
["content"] => string(4) "haha"
["category"] => string(0) ""
["area"] => string(6) "福建"
["add_user"] => NULL
["add_time"] => string(19) "2014-11-22 11:44:26"
}
[3] => array(7) {
["id"] => string(1) "5"
["title"] => string(2) "22"
["content"] => NULL
["category"] => string(0) ""
["area"] => string(6) "福建"
["add_user"] => NULL
["add_time"] => string(19) "2014-11-22 12:40:58"
}
[4] => array(7) {
["id"] => string(1) "6"
["title"] => string(1) "1"
["content"] => string(1) "2"
["category"] => string(0) ""
["area"] => string(6) "福建"
["add_user"] => NULL
["add_time"] => NULL
}
[5] => array(7) {
["id"] => string(1) "7"
["title"] => string(6) "lalala"
["content"] => string(6) "hohoho"
["category"] => string(0) ""
["area"] => string(6) "北京"
["add_user"] => NULL
["add_time"] => NULL
}
}

http://127.0.0.26/index.php/index/article

复制代码
array(6) {
  [0] => array(7) {
    ["id"] => string(1) "1"
    ["title"] => string(4) "test"
    ["content"] => string(12) "test_content"
    ["category"] => string(13) "test_category"
    ["area"] => string(6) "北京"
    ["add_user"] => string(5) "admin"
    ["add_time"] => string(19) "2014-11-20 23:03:44"
  }
  [1] => array(7) {
    ["id"] => string(1) "2"
    ["title"] => string(12) "吼吼吼吼"
    ["content"] => string(18) "任溶溶柔然人"
    ["category"] => string(14) "test_category2"
    ["area"] => string(6) "河北"
    ["add_user"] => string(5) "admin"
    ["add_time"] => string(19) "2014-11-22 15:16:12"
  }
  [2] => array(7) {
    ["id"] => string(1) "4"
    ["title"] => string(7) "test2_m"
    ["content"] => string(4) "haha"
    ["category"] => string(0) ""
    ["area"] => string(6) "福建"
    ["add_user"] => NULL
    ["add_time"] => string(19) "2014-11-22 11:44:26"
  }
  [3] => array(7) {
    ["id"] => string(1) "5"
    ["title"] => string(2) "22"
    ["content"] => NULL
    ["category"] => string(0) ""
    ["area"] => string(6) "福建"
    ["add_user"] => NULL
    ["add_time"] => string(19) "2014-11-22 12:40:58"
  }
  [4] => array(7) {
    ["id"] => string(1) "6"
    ["title"] => string(1) "1"
    ["content"] => string(1) "2"
    ["category"] => string(0) ""
    ["area"] => string(6) "福建"
    ["add_user"] => NULL
    ["add_time"] => NULL
  }
  [5] => array(7) {
    ["id"] => string(1) "7"
    ["title"] => string(6) "lalala"
    ["content"] => string(6) "hohoho"
    ["category"] => string(0) ""
    ["area"] => string(6) "北京"
    ["add_user"] => NULL
    ["add_time"] => NULL
  }
}
复制代码
复制代码

 

例2:让 tpk_article 表的内容根据客户所在的地区显示当地的新闻:

ArticleModel.class.php:

复制代码
复制代码
<?php
class ArticleModel extends Model{
    
    public function article(){
    
        $rows=$this->where("area='{$this->checkUserArea()}'")->select();
        return $rows;
    }

    protected function checkUserArea(){
    
        return "北京";    
    }
复制代码
复制代码

控制器代码:

IndexAction.class.php:

复制代码
复制代码
<?php
class IndexAction extends Action {

    $obj=D("Article");
    $rows=$obj->article();
    $this->assign("list",$rows);
    $this->display();
复制代码
复制代码

同时视图代码:

TPL/Index/article.html:

复制代码
复制代码
<!DOCTYPE html>
<html>
<body>

<volist name="list" id="vo">
    <li><{$vo.title}> - <{$vo.area}> - <{$vo.content}></li>
</volist>

</body>
</html>
复制代码
复制代码

附:数据表 tpk_article 的表结构为:

总结:自定义模型映射,一个模型对应一个数据表,所有增删改查都在模型类中完成。M 实例化的参数是数据库的表名,D 实例化的是自己在 model 文件夹下建立的模型文件。

 

3.create 方法

TP 对数据的插入和更新都做了高度封装:提供了 create() 方法用于创建数据对象。

概念:数据对象 —— 数据字段与数据表之间的关系,数据会被映射为类成员,再与数据表映射,最后实现数据的插入或更新。

create() 方法是连贯操作、CURD 操作的集合 ( 包括数据创建、数据检验、表单验证、自动完成等 )。

cerate() 的数据源由 POST 表单提供,比如表单中有 username 表单元素,则该元素会被自动映射为数据表中的 username 字段。数据对象创建成功以后,对象被存放于内存中。

例:添加数据

控制器:IndexAction,动作:add_article,代码:

IndexAction.class.php:

复制代码
复制代码
<?php
class IndexAction extends Action {

    Public function add_article(){

        $this->display();
    }
}
复制代码
复制代码

视图: Tpl/Index/add_article.html:

复制代码
复制代码
<!DOCTYPE html>
<html>
<body>

    <form method="post" action="__URL__/add">

        <input type="text" name="title" placeholder="标题"><br><br>
        <textarea name="content" id="content" placeholder="内容"></textarea><br><br>
        <input type="submit" name="submit" value="提交">

    </form>

</body>
</html>
复制代码
复制代码

__URL__/add 表示当前控制器的 add 动作。

add 动作代码:

复制代码
复制代码
<?php
class IndexAction extends Action {

    public function add(){

        //表单处理
        $articleObj = M('Article');
        $articleObj->create();
        $articleObj->add_time = date("Y-m-d H:i:s",time());
        if($articleObj->add()){

            $this->success("数据添加成功");
        }else{

            $this->error("数据添加失败");
        }
}
复制代码
复制代码

例子结束。

 

4.模型属性( Model )

 _map 属性:字段映射

为了避免前台表单元素与数据库字段名相同而使数据库字段暴露,可以修改前台表单元素的 name,同时在 Model 中使用 _map 属性。代码:

视图:Tpl/Index/add_article.html:

复制代码
复制代码
<!DOCTYPE html>
<html>
<body>

    <form method="post" action="__URL__/add">

        <input type="text" name="subject" placeholder="标题"><br><br>
        <textarea name="textEdit" id="content" placeholder="内容"></textarea><br><br> 
        <input type="submit" name="submit" value="提交">

    </form>

</body>
</html>
复制代码
复制代码

模型:ArticleModel.class.php:

复制代码
复制代码
<?php
class ArticleModel extends Model{

    //使用_map属性(字段映射)将表单元素映射为相应表字段
    protected $_map = array(
        
        "subject"=>"title",
        "textEdit"=>"content"
    );

}
复制代码
复制代码

控制器:IndexAction.class.php:

复制代码
复制代码
<?php

class IndexAction extends Action {

        $articleObj = D("Article");
        $articleObj->create();
        $articleObj->add_time = date("Y-m-d H:i:s",time());
        if($articleObj->add()){
        
            $this->success("数据添加成功");
        }else{
        
            $this->error("数据添加失败");
        }
}
复制代码
复制代码

例子结束。

 

二、基础模型

1.连贯操作

连贯方法除了 select() 方法外,其他的连贯方法不区分前后顺序。

例:

$rows=$obj->where("add_user='dee'")->order("add_time desc")->limit(10)->select();

 

2.CURD

① 创建数据 add()

复制代码
复制代码
<?php

class IndexAction extends Action {
    
    public function post(){

        $articleObj = D("Article");
        $data['title'] = $_POST['subject'];
        $data['content'] = $_POST['textEdit'];
        $data['add_time'] = date("Y-m-d H:i:s",time());
        if($articleObj->add($data)){

            $this->success("数据添加成功");
        }else{

            $this->error("数据添加失败");
        }
    }
}
复制代码
复制代码

另一个例子:

复制代码
复制代码
<?php

class IndexAction extends Action {
    
    public function post(){

        $articleObj = D("Article");
        $data['title'] = $_POST['subject'];
        $data['content'] = $_POST['textEdit'];
        $data['add_time'] = date("Y-m-d H:i:s",time());
          if($articleObj->data($data)->add()){

            $this->success("数据添加成功");
        }else{

            $this->error("数据添加失败");
        }
    }
}
复制代码
复制代码

 

② 更新数据 save()

复制代码
复制代码
<?php

class IndexAction extends Action {
    public function post2(){

        $articleObj = M("Article");
        $data['id'] = 2;
        $data['title'] = $_POST['subject'];
        $data['content'] = $_POST['textEdit'];
        $data['area'] = '河北';
        $data['add_time'] = date("Y-m-d H:i:s",time());
        if($articleObj->save($data)){

            $this->success("数据修改成功");
        }else{

            $this->error("数据修改失败");
        }
    }
}
复制代码
复制代码

 

 

③ 读取数据 select 和 getFiled

getField 例子:

复制代码
复制代码
<?php

class IndexAction extends Action {

    public function post3(){

        $articleObj = M("Article");
        if($articleObj->where("id=3")->setField("content","{$_POST['subject']}")){

            $this->success("数据修改成功");
        }else{

            $this->error("数据修改失败");
        }
    }
}
复制代码
复制代码

 

④ 删除数据 delete

复制代码
复制代码
<?php

class IndexAction extends Action {
    
    public function delete(){

        $articleObj = M("Article");
        if($articleObj->where("id=".$_GET['id'])->delete()){

            $this->success("数据删除成功");
        }else{

            $this->error("数据删除失败");
        }
    }
}
复制代码
复制代码

 

3.查询语言

例子:

复制代码
复制代码
<?php

class IndexAction extends Action {

    public function archives(){

        $obj = M("Archives");
//      $data['writer'] = array("eq","网络营销中心");
//      $data['title'] = array("like","精诚%");
        $data['id'] = array("lt","100");
        $rows=$obj->where($data)->select();

        $count=$obj->where($data)->count();
        $tb=C("DB_PREFIX");

        $this->assign("list",$rows);
        $this->assign("count",$count);
        $this->assign("tb",$tb);
        $this->display("Article");
    }

        public function archives2(){

        $obj = M("Archives");
        $data['id'] = array(array("lt","1034"),array("GT","1029"),"and");
        $rows=$obj->where($data)->select();
        $this->assign("list",$rows);
        $this->display("Article");
    }
}
复制代码
复制代码

 

可以在控制器中使用 echo $obj->getLastSql(); 查看转换后的 SQL 语句。

 

参考资料:《PHP MVC 开发实战》

分类: PHP
 
 
本文转自左正博客园博客,原文链接: http://www.cnblogs.com/soundcode/p/6944706.html,如需转载请自行联系原作者
相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
JSON Java 关系型数据库
Hutool创建数据源工厂动态查询不同数据库不同数据表的数据
Hutool创建数据源工厂动态查询不同数据库不同数据表的数据
51 2
|
4月前
|
NoSQL 关系型数据库 分布式数据库
基于PolarDB的图分析:通过DTS将其它数据库的数据表同步到PolarDB的图
本文介绍了使用DTS任务将数据从MySQL等数据源实时同步到PolarDB-PG的图数据库中的步骤.
|
6月前
|
缓存 数据库 数据安全/隐私保护
Discuz! X 数据库字典详解:DZ各数据表作用及字段含义
我们使用DISCUZ做网站时,有时需要对数据表进行操作,在操作数据表之前,需要对数据表进行了解。下面是DISCUZ 数据库各数据表作用及字段含义详解,方便新手更好的了解DISCUZ数据库。
130 4
|
6月前
|
关系型数据库 MySQL Java
Django学习二:配置mysql,创建model实例,自动创建数据库表,对mysql数据库表已经创建好的进行直接操作和实验。
这篇文章是关于如何使用Django框架配置MySQL数据库,创建模型实例,并自动或手动创建数据库表,以及对这些表进行操作的详细教程。
211 0
Django学习二:配置mysql,创建model实例,自动创建数据库表,对mysql数据库表已经创建好的进行直接操作和实验。
|
7月前
|
前端开发 IDE 数据库连接
ThinkPHP6 模型层的模型属性,表映射关系,以及如何在控制层中使用模型层和模型层中的简单CRUD
本文详细介绍了ThinkPHP6中模型层的使用,包括模型属性设置、表映射关系、以及如何在控制层中使用模型层进行CRUD操作。
ThinkPHP6 模型层的模型属性,表映射关系,以及如何在控制层中使用模型层和模型层中的简单CRUD
|
7月前
|
前端开发 数据库 开发者
数据模型(数据库表设计)生成代码
BizWorks ToolKit 插件集成 Mybatis-Plus 代码生成工具,支持从数据库表批量生成代码,简化开发流程。本文详细介绍配置方法及项目示例,包括配置文件格式、生成选项及具体操作步骤,帮助开发者快速实现代码同步更新。配置文件 `.mp.yaml` 支持自定义输出目录、生成组件等,适用于多种项目结构。
94 0
|
8月前
|
SQL 存储 NoSQL
从SQL到NoSQL:理解不同数据库类型的选择与应用——深入比较数据模型、扩展性、查询语言、一致性和适用场景,为数据存储提供全面决策指南
【8月更文挑战第31天】在信息技术飞速发展的今天,数据库的选择至关重要。传统的SQL数据库因其稳定的事务性和强大的查询能力被广泛应用,而NoSQL数据库则凭借其灵活性和水平扩展性受到关注。本文对比了两种数据库类型的特点,帮助开发者根据应用场景做出合理选择。SQL数据库遵循关系模型,适合处理结构化数据和复杂查询;NoSQL数据库支持多种数据模型,适用于非结构化或半结构化数据。SQL数据库在一致性方面表现优异,但扩展性较差;NoSQL数据库则设计之初便考虑了水平扩展性。SQL使用成熟的SQL语言,NoSQL的查询语言更为灵活。
180 0
|
8月前
|
API 数据库 开发者
【独家揭秘】Django ORM高手秘籍:如何玩转数据模型与数据库交互的艺术?
【8月更文挑战第31天】本文通过具体示例详细介绍了Django ORM的使用方法,包括数据模型设计与数据库操作的最佳实践。从创建应用和定义模型开始,逐步演示了查询、创建、更新和删除数据的全过程,并展示了关联查询与过滤的技巧,帮助开发者更高效地利用Django ORM构建和维护Web应用。通过这些基础概念和实践技巧,读者可以更好地掌握Django ORM,提升开发效率。
92 0
|
8月前
|
SQL Shell API
python Django教程 之 模型(数据库)、自定义Field、数据表更改、QuerySet API
python Django教程 之 模型(数据库)、自定义Field、数据表更改、QuerySet API
|
8月前
|
SQL 数据库 Windows
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误

热门文章

最新文章