none
Error when upgrading to EF6

    Question

  • I am getting the following error after upgrading a project from EF5 (where everything works) to EF6:

    The property 'Id' cannot be configured as a navigation property. The property must be a valid entity type and the property should have a non-abstract getter and setter. For collection properties the type must implement ICollection<T> where T is a valid entity type.

    It gives no details about what is wrong or which table Id is on (I have dozens of table with name Id).

    I have no idea how to proceed as there is very little I can discern from the error (no inner exception).

    If it matters, the vast majority of my Id's are Guid - is this no longer supported in EF6?

    Thanks


    • Edited by cdasilva Monday, October 28, 2013 2:16 AM
    Monday, October 28, 2013 2:15 AM

Answers

All replies

  • Hello,

    >>is this no longer supported in EF6.

    EF6 supports Guid, of course.

    >>It gives no details about what is wrong or which table Id is on

    I strongly recommend not to name the table primary key to be the same name.

    My suggestion is to rename the ids so that it will give the detail information so that we could mark sure which table causes the problem.

    Or could please share these tables structure so that we can do a test for it?

    And what operation have you done to produce the issue? When building the program or do some operations as CRUD?

    Thanks&Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 28, 2013 6:17 AM
  • Thanks for the reply, sorry if I sounded annoyed - it was a long day.

    Renaming the fields probably isn't a great option right now - I guess it might be possible to map a more detailed entity name to the existing database name. I'll look into that.

    My next step is to grab the EF6 source code and step through to maybe discover more information about what is causing the error. The error occurs at the first access to the database but I believe it's when EF6 does its initial "warmup" before any query is actually executed.

    I will try to create a simple test case with just the entities & context classes. 

    Any changes to navigation properties between EF5 and EF6, something EF5 might have allowed but EF6 doesn't?

    Monday, October 28, 2013 8:55 PM
  • To upgrade to Entity Framework 6, the namespace changes :System.Data.Objects.ObjectContext => System.Data.Entity.Core.Objects.ObjectContext.

    Have a look at:

    http://msdn.microsoft.com/en-us/data/dn469466


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 30, 2013 2:17 AM
  • @cdasilva Did you ever find the cause of this problem? I have just run into the same issue. Thanks
    Saturday, November 16, 2013 3:57 PM