October 16, 2014

Error: Entity framework "Cannot convert from 'System.Data.Objects.ObjectParameter' to 'System.Data.Entity.Core.Objects.ObjectParameter"

Entity Framework ERROR: Cannot convert from 'System.Data.Objects.ObjectParameter' to 'System.Data.Entity.Core.Objects.ObjectParameter[]' entity framework 6


This is one of most frequent compile time error you may face in Entity Framework. This is because either of:

1. Version conflict or
2. Namespace used.


By default, while compiling project, framework includes namespace using System.Data.Objects;


Solution:

To fix this issue:

If version conflicts, install package for respective version of EF.

If version is same, change the above namespace to System.Data.Entity.Core.Objects 


2 comments:

  1. How do I identify 'version conflict' i.e. what versions are conflicting and how do you update so they are the same?

    ReplyDelete
    Replies
    1. Oops! I missed your question, sorry for that. This type of issue causes mainly bcs. of multiple version of installed package. Two ways you can rectify this:

      1. Define version numbers in web.config file.
      2. Remove packages those are no longer use and re-install specific version. This will be easier way.

      Hope this will help to those who is facing similar issue.

      Thanks!

      Delete