FxCop analysed the auto-generated code in edmx files...

This bug is already known: Mircosoft Connect.

The only solution proposed there is from 2010 Customizing the Entity Framework T4 Template, suppressing code analysis.

Do you know some better solution or workaround for this problem?

有帮助吗?

解决方案

You could try using the DbContext templates instead of ObjectContext.

More info:

DbContext was introduced in EF 4.1 as part of Code First and since EF5 has also become the default generated context for Db/Model-first approaches. It uses POCO entities and simplifies a lot of common tasks, which I find makes my model easier to maintain. It also wraps ObjectContext, so you can still call into that if you need to. Since it generates different code, you'd be avoiding the FxCop warnings you are currently seeing, but of course switching to DbContext would require changes to your application code.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top