【应用服务 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的错误

问题情形

使用EF Core访问数据库,在本地运行正常,发布到App Service后,偶尔出现了Cannot create a DbSet for ** because this type is not included in the model for the context,根据错误,初步怀疑是部署的DLL版本不匹配或者丢失。

详细日志

无详细日志

问题原因

根据对错误的分析和源代码中包含中文字符进行分析,应该是客户本地环境中编译后的DLL文件在本地环境本正常识别,但是默认情况下,发布到App Service后,中文识别为乱码,EF Core在加载该类文件时候找不到相应的类型。这点在换一台没有设置中文的windows环境中,问题复现。

解决方案

修改代码中所有中文字符的命名空间和类型名,重新发布后,问题消失。

相关文章
|
Linux Shell 网络安全
【Azure 应用服务】如何来检查App Service上证书的完整性以及在实例中如何查找证书是否存在呢?
【Azure 应用服务】如何来检查App Service上证书的完整性以及在实例中如何查找证书是否存在呢?
292 3
|
安全 Java 应用服务中间件
【Azure 应用服务】App Service 默认页面暴露Tomcat版本信息,存在安全风险
【Azure 应用服务】App Service 默认页面暴露Tomcat版本信息,存在安全风险
368 2
|
Linux C++ Windows
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
465 0
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
|
数据库
【YashanDB数据库】YAS-02032 column type is incompatible with referenced column type
YAS-02032 column type is incompatible with referenced column type
|
SQL Oracle 数据库
使用访问指导(SQL Access Advisor)优化数据库业务负载
本文介绍了Oracle的SQL访问指导(SQL Access Advisor)的应用场景及其使用方法。访问指导通过分析给定的工作负载,提供索引、物化视图和分区等方面的优化建议,帮助DBA提升数据库性能。具体步骤包括创建访问指导任务、创建工作负载、连接工作负载至访问指导、设置任务参数、运行访问指导、查看和应用优化建议。访问指导不仅针对单条SQL语句,还能综合考虑多条SQL语句的优化效果,为DBA提供全面的决策支持。
491 11
|
SQL 关系型数据库 BI
使用 Webshell 访问 SQL Server 主机并利用 SSRS
使用 Webshell 访问 SQL Server 主机并利用 SSRS
|
应用服务中间件 Linux 网络安全
【Azure 应用服务】App Service for Linux 环境中为Tomcat页面修改默认的Azure 404页面
【Azure 应用服务】App Service for Linux 环境中为Tomcat页面修改默认的Azure 404页面
358 5
|
Shell
SqlServer旁门左道之启动报错(cannot find one or more components.Please reinstall the application。)终极解决方案
SqlServer旁门左道之启动报错(cannot find one or more components.Please reinstall the application。)终极解决方案
1187 0
|
Docker 容器
【Azure 应用服务】App Service for Container 无法拉取Docker Hub中的镜像替代方案
【Azure 应用服务】App Service for Container 无法拉取Docker Hub中的镜像替代方案
374 0
|
API C++
【Azure 应用服务】Azure Function App在部署时候遇见 503 ServiceUnavailable
【Azure 应用服务】Azure Function App在部署时候遇见 503 ServiceUnavailable
221 0

热门文章

最新文章