This project is read-only.

Navigation properties not generated

Jul 9, 2013 at 7:16 PM
Edited Jul 9, 2013 at 7:17 PM
Hi,

I've managed to get the classes generated, but my POCO classes do not seem to contain a reference to related objects, only the ID is generated.

I found the thread at https://ef4templates.codeplex.com/discussions/360141 which mentions enabling "ProxyCreation", however I cannot see where that is set.

This is with C#, using .NET 4 in Visual Studio 2010. I have tried with EF5 and then I also tried downgrading to EF4 with the same result.

I setup a simple project to recreate the problem... relationship is picked up in EDMX Model:
 <EntityType Name="Author">
          <Key>
            <PropertyRef Name="Id" />
          </Key>
          <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="FullName" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" />
          <NavigationProperty Name="Books" Relationship="BasicModel.FK_Book_Author" FromRole="Author" ToRole="Book" />
        </EntityType>
But not in generated code:
    public partial class Author
    {
        /// <summary>Initializes a new instance of the <see cref="Author"/> class.</summary>
        public Author()
        {
        }

        /// <summary>Gets or sets the FullName property</summary>
        [DisplayName("Full Name"), Display(Name = "Full Name"), Required, StringLength(50)]
        public string FullName { get; set; }

        /// <summary>Gets or sets the Id property</summary>
        [DisplayName("Id"), Display(Name = "Id"), Required, Key]
        public int Id { get; set; }
    }
Only AuthorId is generated in Book class:
    [System.CodeDom.Compiler.GeneratedCode("EF4Templates", "2.0.0.0")]
    public partial class Book
    {
        /// <summary>Initializes a new instance of the <see cref="Book"/> class.</summary>
        public Book()
        {
        }

        /// <summary>Gets or sets the AuthorId property</summary>
        [DisplayName("Author Id"), Display(Name = "Author Id"), Required]
        public int AuthorId { get; set; }

        /// <summary>Gets or sets the Id property</summary>
        [DisplayName("Id"), Display(Name = "Id"), Required, Key]
        public int Id { get; set; }

        /// <summary>Gets or sets the Title property</summary>
        [DisplayName("Title"), Display(Name = "Title"), Required, StringLength(50)]
        public string Title { get; set; }
    }
What could be the problem? Thanks