简体   繁体   中英

EF Core Analyzer RawSqlStringInjectionDiagnosticAnalyzer error

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.

The problem:

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- 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:

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- Now everytime you build the Asp.net project, you get the same error.

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:

  • Updated my VS to the latest version (15.9.7), no luck
  • Tried to reference different versions of EF Core including Analyzer for both projects, no luck
  • I know Microsoft.CodeAnalysis dll should be a VS internal mechanism, nevertheless tried to reference it manually, no luck
  • Tried to include Microsoft.CodeAnalysis nuget package, no luck
  • Also there were other packages that I have tried, couldn't remember the names now, no luck

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

我已经意识到这应该是警告而不是错误,所以我发现在项目设置中启用了“将警告视为错误”选项,因此这就是我将其视为错误的原因,但是,仍然不知道原因在这个警告的背后。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM