text: Breeze: How can I create a GUID key for new entities on the client? Qubanshi
  I'll assume that your entity is configured such that the client is responsible for setting the Guid key for new entities. That's the default for the Guid key of an Entity Framework Code First entity; it is as if the key property were adorned with [DatabaseGenerated(DatabaseGeneratedOption.None)] The obvious approach is to set the key after creating the entity and before adding it to the manager, e.g.:
  function createFoo() {
  var foo = fooType.createEntity();
  foo.id(breeze.core.getUuid()); // Knockout implementation
  manager.addEntity(foo);
  This may be all you ever need. On the other hand, you may find that you're creating new Foos in many places and for some strange reason you can't use the createFoo function. You certainly don't want to repeat that code. You can extend the Foo entity type with id-setting behavior after which you'd be able to write:
  var foo = fooType.createEntity(); // foo.id is set for you
  There are two approaches to consider - custom constructor and type initializer; both are described in "Extending Entities" Constructor You can initialize the key inside a custom constructor. Breeze calls the constructor both when you create the entity and when it materializes a queried entity. Breeze will replace the initial key value when materializing. Here's an example that assumes the Knockout model library.
  foo.id(breeze.core.getUuid()); // using KO
  // one way to get the MetadataStore
  // register the ctor with the Foo type
  store.registerEntityTypeCtor("Foo", Foo);
  Pretty simple. The only downside is that Breeze will generate a Guid every time it makes an entity, whether creating a new one or materializing one from a query. It's wasted effort during materialization but so what? Well, I suppose that might become a performance issue although I wouldn't assume so until I had measured it. Initializer Suppose you measured and the repeated Guid generation is a serious problem (really?). You could set the key in a type initializer instead and only call the Guid generator when creating a new entity. Breeze calls a type initializer after the entity has been created or materialized from query just before returning that entity to the application. Clearly you don't want to overwrite a materialized key from the database so you'll test the key value to make sure it's not real (i.e. to make sure you're fixing a created entity) before assigning it. Here's an example.
  function fooInitializer(foo) {
  var emptyGuid = "00000000-0000-0000-0000-000000000000";
  if (foo.id() !=== emptyGuid) {
  foo.id(breeze.core.getUuid());
  // register the initializer; no ctor in this example
  store.registerEntityTypeCtor("Foo", function(){}, fooInitializer);
  Assuming you have a Guid surrogate Key on all your entities like we have in our case, you could code a createInstance factory that does the following in a very generic approach: function createInstance(breezeEntityManager, typeName) {
  var keyProperty = breezeEntityManager.metadataStore.getEntityType(typeName, false).dataProperties.filter(function (p) {
  return p.isPartOfKey;
  config[keyProperty.name] = breeze.core.getUuid();
  return breezeEntityManager.createEntity(typeName, config);
  This way, you won't have to create an initializer for all your entities.
  How can I generate DDL from existing entities with annotations using a maven plugin?
  I have maven project and I want to generate DDL from existing entities. How can I do that? Is there any maven plugin that I can generate the DDL? I am using JPA.(open jpa)
  How to create new GUID identity in asp.net?
  Good morning, please, how can I re-create user's profile identity? If non-register user make something, like create order with some profile's properties (like name, surname, phone,...), then he create
  How can I create a new C# Window based on my existing Window?
  I know this mite be a bit of a silly question but how do i create another window from my main window in c# windows application? I don't know where to look for this type of questions.
  I've tried drilling down into the object and looking at the docs but haven't found anything. I've created an entity and I need to assign some properties manually. I see _backingStore and entityAspect Breeze entity Key not set at creation time
  I have the following JS script that creates a product object: var entityQuery = breeze.EntityQuery, manager = configureBreezeManager(); function configureBreezeManager() { breeze.NamingConvention.came
  The reason I want to use a Guid is because in the event that I have to split the database into I won't have primary keys that overlap on both databases. So if I use a Guid there won't be any overlappi
  How can I define a key in EF4.1 Code First on a property that cannot be an identity or guid?
  I have a simple class: public class Member { public int AccountId { get; set; } public string Name { get; set; } public string Role { get; set; } public DateTime MemberSince { get; set; } } I need to
  A client's Django application is intermittently (about twice a day) throwing RuntimeError(Unable to create a new session key.): Traceback (most recent call last): File /usr/local/lib/python2.6/dis
  I am working on an MVC web application using the MVVM pattern, breeze.js and knockout.js. This is the first time I use these js libraries and I still have to grasp how they work. One of the pages of t
  Retrieving device class guid or driver key
  I am trying to find the Device class guid or the Driver key for a particular graphic card device (value can be seen in device manager). I've looked into Win32_VideoController and Win32_DisplayCon
  How can I regenerate entities without deleting them?
  I added a column to one of my MySQL tables and went to go regenerate my entities and while it did appear to be regenerating, I don't see the column I added reflected in the model. Does IntelliJ not su
  I have a breeze / webapi application which has a model that has a navigation property that is a collection of children entities. I can create new child entities and add them to the collection, I can a
  I'd like to create new item that similarly to Util.Map.Entry i.e. that will already contain the structure key,value The problem is that I can't use Map.Entry itself because apperently it's a read-on
  I have 3 entities Project, Attachment and Messages. Project can have multiple attachments and messages. The problem is on the project detail view, I am listing it's messages and it's attachment (if an
  I want to cut some pieces of an audio to create a new audio with this pieces. What library should I use to get it? I would like to do it with DirectSound, but I don´t get with it. Can anybody gives a How can I create users server side in Meteor?
  In the new Meteor auth branch how can I create users server side? I see how to create them client side with the call to [Client] Meteor.createUser(options, extra, callback) But suppose I want to crea
  How can i create a new tab in myaccount page using custom module in drupal.Is there any hooks for that? thanks in advance
  A query already executed with breeze on the client side and I store the results locally. I was really hoping to either .Distinct() or .FirstOrDefault() on the client side so that I can execute locally
  How to create a GUID column? I tried string with :length => 36 but is created varchar(255)
  I want to create a database field to store a GUID. I did this: add_column :users, :user_guid, :string, :length => 36 But it just created a column of varchar(255)
  Let's say I am using a fairly standard 32 character hex GUID, and I have determined that, because it is randomly generated for my users, it is perfect for use as a shard key to horizontally scale writ
  If I have a prototype.js Template which generates HTML code from a JavaScript object, how can I have it automatically escape HTML entities in the JavaScript object's data so that the HTML doesn't brea
  Create GUID of Custom Format
  .NET Allows to create GUID in pre-determined format.. I want to create it with my custom format.. Is it possible?how?
  I am trying to create a Spring Roo entity for a legacy database table. The table does not have a primary key defined. However, Roo will not let me define an entity without an identifierField: @RooEnti
  Sybase: how do I create data that violates foreign key contraint
  I have an existing database with several rows that violate a foreign key constraint. How do I script this situation in a new database? I believe some databases can create constraints that do not valid
  I am trying to configure a Pre Shared Key encrypted connection between a mosquitto mqtt broker and an application written in Java which uses the Eclipse Paho client library. I have successfully made c
  I'd like to use the "nested set model" but I'm obliged to have a GUID as primary key. How can I do without integers as pk?
  I'm not aware how deep my tree will be. So I think the NSM is fit for me, reading some docs. In sql, this model suppose I'm using an integer value as primary key. I thought to create a twin table only
  How can I create a client-side database that persist between sessions?
  I'm working with HTML5 to create a client-side database using the Lawnchair Javascript library, but when y create a new Lawnchair object what i get is a new local storage, not a new database var peop
  Why I can't create new instance of window?
  Why I can't create a new instance of window. When I try: var mywin = new window(); it throws: TypeError: object is not a function I guess window is a static object, is there any way of converting st
  I'm sure I've created my own pain here, but I'm struggling to understand the correct sequence of events to manage creating new entities in my scenario. In my model I have two objects, ObjectA and Obje
  I have a web services that returns some data, which is then transformed into new entities on the server and then passed to the client, where user can edit them. If he chooses to SaveChanges, the entit
  We are using EF5 and SQL Server 2012 the following two classes: public class Question { public Question() { this.Answers = new List<Answer>(); } public int QuestionId { get; set; } public string
  This may seem basic but I can't figure it out. I have a Write Review link which looks as follows: <%= link_to 'Write', new_review_path(@new, :vendor_id => @vendor.id) %> This creates the U
  How do I set a Guid using Microsoft Unity
  I don't get it. I can't find any docs on this seemingly innocuous problem. I have tried 4 different formats: 1) brace+lower <property name=DefaultImpactID propertyType=System.Guid> <valu
  How can I get Breeze.js to save my timezone in my SQL DB
  We are trying to sort out how to have a user input a date-time with a timezone and save that in my SQL database. I have a column of type datetimeoffset in my SQL server. $scope.saveItemChanges = fun
  Assuming I had the following tables: If I now set up a many-to-many relationship in NHibernate, the <key column /> attribute below will map the PublisherArticles.VersionIndependentArticleId to How can I dynamically create a new .java file from a Java program?
  How can I know it a user is not authorized to do a Breeze query? I've added the Authorize attribute to a query of my Breeze controller: [BreezeController] public class GamesController : ApiController How can I create an object dynamically?
  I would like to create a list of objects to replace this method of creating them: var colors= new List<object>() { new {key=1,value=red}, new {key=2,value=white}, new {key=3,value=bl
  How can I create a new Date object in IRB with a given date. The following didn't work. 1.9.3p194 :053 > require 'active_support' => true 1.9.3p194 :054 > Date.new => #<Date:0x9d80730&g
  I came across a scenario where I had to use Union all, how can I achieve so in LINQ to entities ?
  How can create the SSLSocket key in the code?
  in java, client must use the key file to connect server.how can i init it in the code? i want server create the key in code. What to do? ths for u Answer