EF核心分析器RawSqlStringInjectionDiagnosticAnalyzer错误 [英] EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer error

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

问题描述

我正在尝试将所有内容从Entity Framework 6.3移植到Entity Framework Core 2.1.2,这是我第一次使用EF Core.我有2个项目,一个是我的核心或基础结构项目,其中包含所有实体模型,DB Context和存储库,另一个是asp.Net MVC,这是我的启动项目,并使用了核心项目中的所有服务.这两个项目都使用.NetStandard库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:\ Users \ user \ .nuget \ packages \ microsoft.entityframeworkcore.analyzers \ 2.1.2 \ analyzers \ dotnet \ cs \ Microsoft.EntityFrameworkCore.Analyzers.dll:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 2.8.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35'或它的依赖项之一.系统找不到指定的文件.

An instance of analyzer Microsoft.EntityFrameworkCore.RawSqlStringInjectionDiagnosticAnalyzer cannot be created from C:\Users\user\.nuget\packages\microsoft.entityframeworkcore.analyzers\2.1.2\analyzers\dotnet\cs\Microsoft.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天的时间在整个Internet上进行此问题搜索,有些人遇到了类似的问题(

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核心分析器RawSqlStringInjectionDiagnosticAnalyzer错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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