invalid association mapping

Last post 07-06-2009 10:07 AM by pharcyde. 1 replies.

Sort Posts:

  • invalid association mapping

    07-29-2008, 2:58 PM
    Hi , wondering if anyone has any ideas to this within my class mapping. I think the answer maybe in my db structure.
    Anyway, all thoughts very much appreciated.

    Invalid association mapping for member 'Asset.DesignImages'.  'DesignImage' is not an entity

    I've notice VS studio is giving me warnings:

    Warning    1    Value for property "Discriminator Property" cannot be empty.        0    0   
    Warning    2    Value for property "Inheritance Default" cannot be empty.        0    0   

    My DataBase
    Asset
    DesignText (foreignkey to asset.id )
    DesignImage (foreignkey to asset.id )

    Maybe i'm gettng nulls???

     var query =

      from d in db.Designs

      from a in db.Assets

      select new ProductViewHelper()

      {

        theDesign = new Design(){DesignId = d.Id, Title = d.Title, DateField = DateTime.Now, PreviewImage = d.PreviewImage},

        theAsset = new Asset(){AssetId = a.Id, DesignId = a.DesignId, Date = a.Date},

        DesignTexts = (from x in a.DesignTexts select new DesignText()

        { DesignTextId = x.Id, Text = x.Text}).ToList(),

        DesignImages = (from y in a.DesignImages select new DesignImage()
       
        {Id = y.Id}).ToList()

      };


            foreach (var p in query)
            {
        
                    Response.Write(p.theAsset.id);

              
            }
  • Re: invalid association mapping

    07-06-2009, 10:07 AM
    • Member
      528 point Member
    • pharcyde
    • Member since 09-26-2003, 12:07 PM
    • Tampa, Florida
    • Posts 109
    This is because the DesignImage table does not have a primary key. Entities are unique objects that need a descriminating key. So, either remove the relationship or add a primary key to the table.
    ~Pharcyde
    .NET Developer and MVC Advocate
Page 1 of 1 (2 items)