DBML1062 & DBML1011 Errors RRS feed

  • Question

  • I encountered an issue in “Linq to Class” design.

    I have multiple database views and tables. When I created DBML file, I dragged table “Account” and view “MappingDetail”  into graphs.

    I manually created an association from Account to MappingDetail (Account.AccountID = MappingDetail.MasterAccountID, 1 to many). When I save the DBML file, I got this message:

    Warning            1          DBML1062: The Type attribute 'MappingDetail' of the Association element 'Account_MappingDetail' of the Type element 'Account' does not have a primary key.  No code will be generated for the association.                   0          0           

    Warning            2          DBML1011: The Type element 'MappingDetail' contains the Association element 'Account_MappingDetail' but does not have a primary key.  No code will be generated for the association.                 0          0           

    And I checked class MappingDetail and Account, associations are not generated.

    How to fix this issue.

    Your help would be appreciated.

    Thank in advance.


    Monday, July 27, 2009 9:04 PM


  • Are Account and MappingDetail tables? If so, why do they not have primary keys in your database?

    If they are views or for some obscure reason you can't actually give your tables primary keys then you can go into the LINQ to SQL designer and determine what the unique primary key for each table would be then set the primary key property to true for each table's key members.

    Tuesday, July 28, 2009 1:40 AM