Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Entity Framework Problem

Entity Framework Problem

Scheduled Pinned Locked Moved C#
helpcomquestionlearningworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    I installed the EF CTP4 from here[^] I am now trying to configure a mapping:

    using System.Data.Entity.ModelConfiguration;
    using Falcon.Entities.Entities;

    namespace Falcon.DAL.Configuration
    {
    public class ClientConfiguration : EntityConfiguration
    {
    public ClientConfiguration()
    {
    Property(c => c.Id).IsIdentity();
    Property(c => c.ClientName).HasMaxLength(50).IsRequired();
    Property(c => c.IsActive);

            Relationship(c => c.Company).IsRequired();
        }
    }
    

    }

    It can't find Relationship. All the code examples and the book I'm using have this. Anyone know what's wring here?

    If it's not broken, fix it until it is

    U 1 Reply Last reply
    0
    • K Kevin Marois

      I installed the EF CTP4 from here[^] I am now trying to configure a mapping:

      using System.Data.Entity.ModelConfiguration;
      using Falcon.Entities.Entities;

      namespace Falcon.DAL.Configuration
      {
      public class ClientConfiguration : EntityConfiguration
      {
      public ClientConfiguration()
      {
      Property(c => c.Id).IsIdentity();
      Property(c => c.ClientName).HasMaxLength(50).IsRequired();
      Property(c => c.IsActive);

              Relationship(c => c.Company).IsRequired();
          }
      }
      

      }

      It can't find Relationship. All the code examples and the book I'm using have this. Anyone know what's wring here?

      If it's not broken, fix it until it is

      U Offline
      U Offline
      Unnikrishnan_S_N
      wrote on last edited by
      #2

      Hi Kevin, I think you have to associate by providing the foreign key in the relationship.

      Property(c => c.Company).IsRequired().WithMany()
      .HasForeignKey(u => u.CompanyId);

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups