EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer 错误 [英] EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer error

查看:30
本文介绍了EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将所有内容从 Entity Framework 6.3 移植到 Entity Framework Core 2.1.2,这是我第一次使用 EF Core.我有 2 个项目,一个是我的核心或基础设施项目,包含所有实体模型、DB 上下文和存储库,另一个是 asp.Net MVC,它是我的启动项目并使用核心项目的所有服务.这两个项目都使用 .NetStandard Library 2.0.3 和目标 .Net Framework 4.6.2.我的机器上有 .Net Core SDK 2.2.

I am trying to port everything from Entity Framework 6.3 to Entity Framework Core 2.1.2 and this is my first experience with EF Core. I have 2 projects one is my core or infrastructure project with all the entity models, DB Context and repositories and the other one is an asp.Net MVC which is my startup project and using all the services from the core project. Both projects are using .NetStandard Library 2.0.3 and targeted .Net Framework 4.6.2. And I have .Net Core SDK 2.2 on my machine.

问题:

1- 将所有内容转换为 Entity Framework Core(所有实体映射、上下文和存储库),所有内容看起来都很好,两个项目都成功构建.

1- Converted everything to Entity Framework Core (All the entity mappings, contexts and repositories) and all the stuff seems fine, both projects build successfully.

2- 开始针对现有数据库和实体模型的首次迁移.现在,在构建这两个项目的迁移过程中,我在 asp.net MVC 项目上遇到了一个奇怪的错误,如下所示:

2- starting first migration targeting existing database and entity models. Now while the migration process building both projects I am getting a strange error on asp.net MVC project as following:

分析器的一个实例Microsoft.EntityFrameworkCore.RawSqlStringInjectionDiagnosticAnalyzer不能从C:Usersuser.nugetpackagesmicrosoft.entityframeworkcore.analyzers2.1.2analyzersdotnetcsMicrosoft.EntityFrameworkCore.Analyzers.dll: 无法加载文件或程序集Microsoft.CodeAnalysis,版本=2.8.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35' 或它的依赖项之一.系统找不到指定的文件.

An instance of analyzer Microsoft.EntityFrameworkCore.RawSqlStringInjectionDiagnosticAnalyzer cannot be created from C:Usersuser.nugetpackagesmicrosoft.entityframeworkcore.analyzers2.1.2analyzersdotnetcsMicrosoft.EntityFrameworkCore.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

3- 现在每次构建 Asp.net 项目时,都会遇到同样的错误.

3- Now everytime you build the Asp.net project, you get the same error.

我真的不知道这个 RawSqlStringInjectionDiagnosticAnalyzer 以及为什么它甚至被项目使用,到目前为止我已经花了 2 天时间在整个互联网上搜索这个问题,有些人遇到了一些类似的问题(喜欢这个)但找不到任何解决方案,我所做的一些事情是:

I really have no idea about this RawSqlStringInjectionDiagnosticAnalyzer and why this being even used by the projects, I have spent 2 days so far on this problem search all over the Internet, some people experienced somewhat similar problems (like this one) but could not found any solution, some of the stuff that I did was:

  • 将我的 VS 更新到最新版本 (15.9.7),没有运气
  • 尝试为两个项目引用不同版本的 EF Core,包括分析器,但没有成功
  • 我知道 Microsoft.CodeAnalysis dll 应该是 VS 的内部机制,但尝试手动引用它,没有运气
  • 尝试包含 Microsoft.CodeAnalysis nuget 包,但没有运气
  • 还有其他我试过的包,现在不记得名字了,运气不好

请帮帮我,我厌倦了添加和引用不同的包和二进制文件,我什至无法理解问题所在.

Please help me I am tired of adding and referencing different packages and binaries, I can't even grasp the problem.

推荐答案

我意识到这应该是警告而不是错误,所以我发现项目设置中的将警告视为错误"选项已启用,所以原因我将此视为错误,但是,仍然不知道此警告背后的原因.

I have realized this should be a warning and not an error so I found out that the "Treat warning as error" options in the project settings is enabled so that's reasons I am getting this as an error, however, still do not know the reason behind this warning.

这篇关于EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆