none
Cannot implicitly convert type 'ProjName.ModelFolderName.EntityClassName' to 'System.Data.Entity.Core.EntityKey'

    Question

  • HI All,

    I am quite new to entity framework.

    Tried a simple database insert using the entityframework, but I am getting the below error

    Here in the below error message, the entity classname is the class created from the entityframework configuraiton

    When I am trying to save a record its giving this message.

    Can you please help us on this.

    Cannot implicitly convert type 'ProjName.ModelFolderName.EntityClassName' to 'System.Data.Entity.Core.EntityKey'

    Saturday, April 6, 2019 9:16 AM

All replies

  • I don't know what your code looks like, but you need to understand OO principles 101. An class/object can't be made into another class/object. A class is a blueprint to an object, the class has variables, properties and  methods/behavior that is unique to the class/object. So EntityClassName can never be an EntityKey.

    OO is OO the principles are the same for .NET or Java.

    https://alfredjava.wordpress.com/2008/07/08/class-vs-object-vs-instance/

     
    Saturday, April 6, 2019 10:32 AM
  • Hi Techasuran,

    can you post the code of the Insert method you are using and the inner exception message!

    Best Regards,

    Mouad.

    Saturday, April 6, 2019 11:10 AM
  • Hi All,

    Thank you for your support, There was some extra code which was assigning some value after saving.

    I removed that and it worked

    Saturday, April 6, 2019 12:40 PM
  • Perfect :)
    Good Coding;

    Saturday, April 6, 2019 3:27 PM