Null Reference when submitting Umbraco Forms to custom data source
<p>I'm trying to make <strong>Umbraco Forms</strong> (Umbraco v7.5.3) save to my own data source.
I followed this guide: <a href="http://www.nibble.be/?p=84" rel="nofollow noreferrer">http://www.nibble.be/?p=84</a></p>

<p>And it appears to work-ish. I can connect and generate a form based on the table. Which is nice.</p>

<h2>My setup</h2>

<ol>
<li><p>I add a new forms data source with the connection string:</p>

<pre><code>Provider=SQLNCLI11;Server=(localdb)\MSSQLLocalDB;Database=test;Integrated Security=SSPI;
</code></pre></li>
<li><p>My table looks like this:</p>

<p><a href="https://i.stack.imgur.com/lPNfk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lPNfk.png" alt="table"></a></p>

<p>The Id (PK) property is configured as Identity</p></li>
<li><p>I choose some fields I want to use in the form:</p>

<p><a href="https://i.stack.imgur.com/pVIyn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pVIyn.png" alt="field selection"></a></p></li>
<li><p>I choose which data types it should use:</p>

<p><a href="https://i.stack.imgur.com/7gGpK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7gGpK.png" alt="field types"></a></p>

<p>I'm a bit puzzled why the <code>Id</code> field is there. I didn't select it, and the guide I followed didn't have this field either :/?</p></li>
<li><p>It generates this form for me:</p>

<p><a href="https://i.stack.imgur.com/hpoia.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hpoia.png" alt="generated form"></a></p></li>
</ol>

<h2>Error</h2>

<p>But when I try to submit form data I get the following error. Which isn't nice.</p>

<blockquote>
  <p>Server Error in '/' Application.</p>
  
  <p>Object reference not set to an instance of an object.</p>
  
  <p>Description: An unhandled exception occurred during the execution of
  the current web request. Please review the stack trace for more
  information about the error and where it originated in the code. </p>
  
  <p>Exception Details: System.NullReferenceException: Object reference not
  set to an instance of an object.</p>
  
  <p>Source Error: </p>
  
  <p>An unhandled exception was generated during the execution of the
  current web request. Information regarding the origin and location of
  the exception can be identified using the exception stack trace below.</p>
  
  <p>Stack Trace: </p>
  
  <p>[NullReferenceException: Object reference not set to an instance of an
  object.]<br>
  Umbraco.Forms.Core.Providers.DatasourceTypes.MsSql.InsertRecord(Record
  record) +1750<br>
  Umbraco.Forms.Web.Services.RecordService.storeRecord(Record record,
  Form form) +1574<br>
  Umbraco.Forms.Web.Services.RecordService.Approve(Record record, Form
  form) +343    Umbraco.Forms.Web.Services.RecordService.Submit(Record
  record, Form form) +565<br>
  Umbraco.Forms.Web.Controllers.UmbracoFormsController.SubmitForm(Form
  form, FormViewModel model, Dictionary<code>2 state, ControllerContext
  context) +2245<br>
  Umbraco.Forms.Web.Controllers.UmbracoFormsController.GoForward(Form
  form, FormViewModel model, Dictionary</code>2 state) +205<br>
  Umbraco.Forms.Web.Controllers.UmbracoFormsController.HandleForm(FormViewModel
  model, Boolean captchaIsValid) +785    lambda_method(Closure ,
  ControllerBase , Object[] ) +143<br>
  System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
  controller, Object[] parameters) +14<br>
  System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
  controllerContext, IDictionary<code>2 parameters) +157<br>
  System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
  controllerContext, ActionDescriptor actionDescriptor, IDictionary</code>2
  parameters) +27<br>
  System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult
  asyncResult, ActionInvocation innerInvokeState) +22<br>
  System.Web.Mvc.Async.WrappedAsyncResult<code>2.CallEndDelegate(IAsyncResult
  asyncResult) +29<br>
  System.Web.Mvc.Async.WrappedAsyncResultBase</code>1.End() +49<br>
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
  asyncResult) +32<br>
  System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d()
  +50    System.Web.Mvc.Async.&lt;>c__DisplayClass46.b__3f()
  +225    System.Web.Mvc.Async.&lt;>c__DisplayClass46.b__3f()
  +225    System.Web.Mvc.Async.&lt;>c__DisplayClass46.b__3f()
  +225    System.Web.Mvc.Async.&lt;>c__DisplayClass46.b__3f()
  +225    System.Web.Mvc.Async.&lt;>c__DisplayClass46.b__3f()
  +225    System.Web.Mvc.Async.&lt;>c__DisplayClass33.b__32(IAsyncResult asyncResult) +10<br>
  System.Web.Mvc.Async.WrappedAsyncResult<code>1.CallEndDelegate(IAsyncResult
  asyncResult) +10<br>
  System.Web.Mvc.Async.WrappedAsyncResultBase</code>1.End() +49<br>
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
  asyncResult) +34<br>
  System.Web.Mvc.Async.&lt;>c__DisplayClass2b.b__1c()
  +26    System.Web.Mvc.Async.&lt;>c__DisplayClass21.b__1e(IAsyncResult
  asyncResult) +100<br>
  System.Web.Mvc.Async.WrappedAsyncResult<code>1.CallEndDelegate(IAsyncResult
  asyncResult) +10<br>
  System.Web.Mvc.Async.WrappedAsyncResultBase</code>1.End() +49<br>
  System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
  asyncResult) +27<br>
  System.Web.Mvc.Controller.b__1d(IAsyncResult
  asyncResult, ExecuteCoreState innerState) +13<br>
  System.Web.Mvc.Async.WrappedAsyncVoid<code>1.CallEndDelegate(IAsyncResult
  asyncResult) +29<br>
  System.Web.Mvc.Async.WrappedAsyncResultBase</code>1.End() +49<br>
  System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
  System.Web.Mvc.Controller.b__15(IAsyncResult
  asyncResult, Controller controller) +12<br>
  System.Web.Mvc.Async.WrappedAsyncVoid<code>1.CallEndDelegate(IAsyncResult
  asyncResult) +22<br>
  System.Web.Mvc.Async.WrappedAsyncResultBase</code>1.End() +49<br>
  System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26<br>
  System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
  asyncResult) +10<br>
  System.Web.Mvc.MvcHandler.b__5(IAsyncResult
  asyncResult, ProcessRequestState innerState) +21<br>
  System.Web.Mvc.Async.WrappedAsyncVoid<code>1.CallEndDelegate(IAsyncResult
  asyncResult) +29<br>
  System.Web.Mvc.Async.WrappedAsyncResultBase</code>1.End() +49<br>
  System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
  +28    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
  result) +9<br>
  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  +9765121    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155</p>
</blockquote>

<h2>Questions</h2>

<ul>
<li>Why is the <code>Id</code> field added to my form when I didn't select it?</li>
<li>How is the form linked to my table? When I create a new form I cannot set a data source for it, and I cannot find any config on the generated form that points to my data source.

<ul>
<li>How are form fields linked to a table column? Is it via the "display name"?</li>
</ul></li>
<li>Why do I get the above <code>Null Reference</code> when trying to submit my form?</li>
</ul>