Ask a questionAsk a question
 

AnswerRequired properties with EF4?

  • Friday, October 23, 2009 6:21 AMDevlife3 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    So I have done a bunch of work in EF4 beta 1 with POCO classes.
    However, after updating to EF4 beta 2 I updated my edmx from the database and found that it is now requiring me to have additional properties in my poco classes.
    For example:


    Table User:
    ID int, primary key, identity(1,1)
    Username nvarchar(20), not null
    PersonID int, foreign key to person table

    Table Person
    ID int, primary key, identity(1,1)
    Name nvarchar(50), not null


    In my poco classes I am now required to have:

    public class User
    {
        public int ID { get; set; }
        public string Username { get; set; }
        public Person { get; set; }
        public int PersonID { get; set; }
    }


    Why am I now required to have the PersonID property?
    Any help would be much appreciated!


    Thanks,
    Mike

Answers

  • Saturday, October 24, 2009 5:58 AMDiego B VegaMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Mike,

    We have added support for Foreign Keys in conceptual model in Beta 2. The designer component will usually ask you whether you want to add them in the wizard used to create a new Entity Data Model from the database, and also when you updated the model from the database. Make sure you turn off this option in the wizard if you don’t want them.

    After you select the option “Update Model from Database...” look for a check box with the text “Include foreign key columns in the model” at the bottom of the “Update Wizard” dialog and make sure it is unselected.

    Hope this helps,
    Diego


    This posting is provided "AS IS" with no warranties, and confers no rights.

All Replies

  • Saturday, October 24, 2009 5:58 AMDiego B VegaMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Mike,

    We have added support for Foreign Keys in conceptual model in Beta 2. The designer component will usually ask you whether you want to add them in the wizard used to create a new Entity Data Model from the database, and also when you updated the model from the database. Make sure you turn off this option in the wizard if you don’t want them.

    After you select the option “Update Model from Database...” look for a check box with the text “Include foreign key columns in the model” at the bottom of the “Update Wizard” dialog and make sure it is unselected.

    Hope this helps,
    Diego


    This posting is provided "AS IS" with no warranties, and confers no rights.