How can we improve Breeze.js?

Support autogenerated keys for entities with multipart keys

6 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Julian Yuste shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • Ward Bell commented  ·   ·  Flag as inappropriate

    You can't use multi-part key in a navigation property. We certainly DO support multi-part PKs (see Northwind OrderDetail which has an OrderID and a ProductID).

    Either property of a multipart PK can be autogenerated.

    And if you don't like what we do, you can create your own keygeneration strategy and make it yourself. Breeze has an extension for that.

    Consequently, not sure what it is that you want to do that we can't do ... unless it is navigate w/ two-part key ... in which case ... you'll have to write your own navigation property to do that.

  • momma commented  ·   ·  Flag as inappropriate

    This is so stupid. Why even allow multipart keys if breeze can't support autogenerated key?

  • Julian Yuste commented  ·   ·  Flag as inappropriate


    What i'm trying to do is exactly what Jay Traband is saying is his answer to the stackoverflow question.

    I'll reproduce the answer here:

    Actually having a multipart key where part of the key is autogenerated is actually pretty common. This usually occurs with legacy databases where the primary key consists of a foreign key property and a 'autogenerated' sequence number property. Usually this autogenerated key is not globally unique by itself, but only in conjunction with the foreign key property. Think of an orderDetail with a foreign key of "OrderId, SequenceNumber".

    What doesn't seem to make as much sense is when the primary key consists of more than one autogenerated property.

    In Breeze the autogenerated keys are intended to be globally unique. Whereas, in the multipart key mentioned above the SequenceNumber would not be globally unique ( and if it were then why not make it the primary key all by itself).

    Does this make sense?

  • frizzyH commented  ·   ·  Flag as inappropriate

    I'm working on multitenant application so my PK consists of ProductId (identity) and TenantId and there is no way to set PK as ProductId only.

    But I've succeeded to solve the problem by using MetadataStore.registerEntityTypeCtor and defining own initialization function that filled PK fields.
    Then I've faced the other problem "Internal Error in key fixup - unable to locate entity" and solved it by replacing EntityGroup._fixupKey function with my custom function with only one changed string:

    var ix = this._indexMap[tempValue + ":::" + TenantId];

    I guess it would be very helpful if you describe this way somewhere in the doc.

  • AdminAdmin (Product Manager, Breeze.js) commented  ·   ·  Flag as inappropriate

    Roger that. Moving this back to under review.

    Frizzy, will you please give us more information on your use case for this request?

    Given that Breeze supports auto-generated keys, and Breeze supports multi-part keys, what scenarios do you find using both at the same time to be helpful?



  • frizzyH commented  ·   ·  Flag as inappropriate

    The problem is not resolved. It just says that you can not use multipart keys with Breeze.

Feedback and Knowledge Base