define(['jquery', 'backbone', 'knockout', 'knockout-mapping', 'underscore'], function ($, Backbone, ko, koMapping, _) {
    return Backbone.View.extend({
        viewModel: null,
        key: '',
        pkField: '',

        events: {
            'click .add-button': 'addItem',
            'click .arches-CRUD-delete ': 'deleteItem',
            'click .arches-CRUD-edit ': 'editItem'
        },

        initialize: function(options) {
            _.extend(this, _.pick(options, 'viewModel', 'key', 'pkField', 'validateBranch'));

            _.each(this.viewModel[this.key], function (item) {
                item.tempId = '';
            });
            this.viewModel.defaults[this.key].tempId = '';

            this.viewModel[this.key] = ko.observableArray(this.viewModel[this.key]);
            this.viewModel.editing[this.key] = koMapping.fromJS(this.viewModel.defaults[this.key]);
        },

        validateBranch: function (data) {
            return true;
        },

        addItem: function() {
            var data = ko.toJS(this.viewModel.editing[this.key]),
                validationAlert = this.$el.find('.branch-invalid-alert');
            if (this.validateBranch(data)) {
                if (!data[this.pkField] && !data.tempId) {
                    data.tempId = _.uniqueId('tempId_');
                }
                delete data.__ko_mapping__;
				this.trigger('change', 'add', data);
                this.viewModel[this.key].push(data);
                koMapping.fromJS(this.viewModel.defaults[this.key], this.viewModel.editing[this.key]);
            } else {
                validationAlert.show(300);
                setTimeout(function() {
                    validationAlert.fadeOut();
                }, 5000);
            }
        },

        matchItem: function(item, data) {
            var matchField = this.pkField;
            if (!data[matchField.toLowerCase()]) {
                matchField = 'tempId';
            }
            return item[matchField] === data[matchField.toLowerCase()];
        },

        deleteItem: function(e) {
            var self = this,
                data = $(e.target).data();

            this.viewModel[this.key].remove(function(item) {
                if(self.matchItem(item, data)){
                    self.trigger('change', 'delete', item);   
                    return true;                 
                }
                return false;
            });
        },

        editItem: function(e) {
            var self = this,
                data = $(e.target).closest('.arches-CRUD-edit').data();

            this.viewModel[this.key].remove(function(item) {
                var match = self.matchItem(item, data);
                if (match) {
                    self.trigger('change', 'edit', item);
                    koMapping.fromJS(ko.toJS(item), self.viewModel.editing[self.key]);
                }
                return match;
            });
        }
    });
});
@@ -526,17 +526,16 @@
 nch'));%0A
-%0A
         
@@ -542,93 +542,91 @@
     
-_.each(this.viewModel%5Bthis.key%5D, function (item) %7B%0A                item.tempId = '';%0A
+if (this.pkField === '')%7B%0A                this.pkField = this.key + '__entityid';  
     
@@ -629,30 +629,27 @@
             
-%7D);%0A
   
+%0A
           th
@@ -650,54 +650,11 @@
     
-this.viewModel.defaults%5Bthis.key%5D.tempId = '';
+  %7D
 %0A%0A  
@@ -1021,17 +1021,17 @@
 is.key%5D)
-,
+;
 %0A       
@@ -1027,35 +1027,35 @@
 %5D);%0A            
-   
+var
  validationAlert
@@ -1101,32 +1101,45 @@
 ');%0A            
+%0A            
 if (this.validat
@@ -1158,142 +1158,8 @@
 )) %7B
-%0A                if (!data%5Bthis.pkField%5D && !data.tempId) %7B%0A                    data.tempId = _.uniqueId('tempId_');%0A                %7D
 %0A   
@@ -1603,281 +1603,8 @@
 %7D,%0A%0A
-        matchItem: function(item, data) %7B%0A            var matchField = this.pkField;%0A            if (!data%5BmatchField.toLowerCase()%5D) %7B%0A                matchField = 'tempId';%0A            %7D%0A            return item%5BmatchField%5D === data%5BmatchField.toLowerCase()%5D;%0A        %7D,%0A%0A
     
@@ -1653,37 +1653,8 @@
 var 
-self = this,%0A                
 data
@@ -1668,33 +1668,33 @@
 target).data();%0A
-%0A
+ 
             this
@@ -1680,32 +1680,42 @@
 ();%0A            
+var item =
  this.viewModel%5B
@@ -1727,105 +1727,41 @@
 key%5D
-.remove(function(item) %7B%0A                if(self.matchItem(item, data))%7B%0A                    self
+()%5Bdata.index%5D;%0A%0A            this
 .tri
@@ -1811,107 +1811,78 @@
     
-   
-     return true;                 %0A                %7D%0A                return false;%0A            %7D
+this.viewModel%5Bthis.key%5D.remove(this.viewModel%5Bthis.key%5D()%5Bdata.index%5D
 );%0A 
@@ -1944,37 +1944,8 @@
 var 
-self = this,%0A                
 data
@@ -1996,17 +1996,17 @@
 data();%0A
-%0A
+ 
         
@@ -2000,32 +2000,42 @@
 ();%0A            
+var item =
  this.viewModel%5B
@@ -2047,142 +2047,41 @@
 key%5D
-.remove(function(item) %7B%0A                var match = self.matchItem(item, data);%0A                if (match) %7B%0A                    self
+()%5Bdata.index%5D;%0A%0A            this
 .tri
@@ -2110,24 +2110,16 @@
  item);%0A
-        
         
@@ -2154,20 +2154,20 @@
 (item), 
-self
+this
 .viewMod
@@ -2181,12 +2181,12 @@
 ing%5B
-self
+this
 .key
@@ -2205,57 +2205,44 @@
     
-    %7D%0A                return match;%0A            %7D
+this.viewModel%5Bthis.key%5D.remove(item
 );%0A 

remove the need to have a tempId field added to the model, use the index instead to get the item in the model list