1

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?

MikroDel
  • 6,705
  • 7
  • 39
  • 74
  • What do you mean by better solution? Are you looking for a tool that helps you suppress the FxCop error? Or are you looking a way you can modify the T4 template itself? Or something else? Please specify. – SBirthare Jun 27 '13 at 12:10
  • If you are looking for a tool to ease fixing such warning or error, check http://stackoverflow.com/questions/1359819/is-there-a-stylecop-fxcop-autofixing-tool – SBirthare Jun 27 '13 at 12:13
  • @user1529150 - better solution - some new approaches to solve it - cause it is already 3 year gone since the bug was encountered – MikroDel Jun 27 '13 at 12:17
  • You could try using the DbContext templates instead of ObjectContext. – smudge Jun 27 '13 at 17:37
  • @Smudge why should I try it? – MikroDel Jul 01 '13 at 06:51
  • @MikroDel DbContext was introduced in 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. – smudge Jul 01 '13 at 18:13
  • @Smudge - thanks for your hint - if you are sure that DContext generate FxCop accepted code.. – MikroDel Jul 02 '13 at 05:51
  • @Smudge - post your comment about DbContext as an answer and I will accept and upvote it. You will earn some points =) – MikroDel Jul 03 '13 at 13:56

1 Answers1

1

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.

smudge
  • 801
  • 1
  • 6
  • 21