我想禁止显示这些警告,但是我不知道该怎么做.
I would like to suppress these warnings but I could not figure out how to do it.
推荐答案
这些不是您看到的警告,而是错误.当诊断消息是警告或错误时,输出将非常清楚地告诉您.您已为编译器提供了一个错误编号(6002),并告诉它使用该编号禁止显示警告,但是这种警告不存在.因此,您仅成功创建了另一个错误
Those are not warnings you are seeing, those are Errors. The output tells you very clearly when a diagnostic message is a warning or an error. You've given the compiler an error number (6002) and told it to suppress the warning with that number, but such a warning does not exist. So, you've only succeeded in creating an additional error
在这种情况下,您要抑制的消息是致命的编译器错误;您唯一的选择是修复您的代码.您必须为每个Entity Framework对象定义一个主键,否则Entity Framework将无法使用它.错误的措辞有点令人困惑,因为它暗示编译器以某种方式解决"了您的问题,但事实并非如此.
In this case, the message you're trying to suppress is a fatal compiler error; your only option is to fix your code. You must define a primary key for every Entity Framework object, or the Entity Framework will not work with it. The wording of the error is a bit confusing, as it implies that somehow the compiler has "worked around" your problem, but that's not the case.
有关该特定错误及其修复方法的更多详细信息:
For more details about that specific error, and how to fix it:
错误6002:表格/view没有定义主键
更多推荐
抑制EF警告的正确方法是什么?
发布评论