Entity Framework 4.1 Code First Create Journal Type Field RRS feed

  • Question

  • I am pretty new to EF 4, I have used NHibernate and NEO before, but this is an issue with all of these systems that I have seen in the past. 

    I am building a bug tracker, just to play around.  I want to be able to add Comments to multiple different types of Entities.  So therefore, my Table Structure would usually be to have a Journal table where the primary keys are the ID and a string field containing the foreign table name (or Entity name). 

    Any suggestions on how to go about this with EF 4.1?  The ways I have tried all seem to generate a new ID on the Journal table for each entity it is linked to.

    Wednesday, October 26, 2011 11:51 PM


  • Hi Chris,

    To tell you truth, I'm not familiar with NHibenate and NEO, according to your description, I think you want to insert a 1 to many relationship by Code Frist, right?

    There is navigation in each entity, you should retrieve "Journal" type and insert from other entities and set the Journal property.

    If I misunderstood you, would you please share some code with me, thanks for understanding.

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 31, 2011 6:52 AM