title: Using ASP.NET SqlMembershipProvider with GUID UserID in MVC4 web application
body: <p>I have an existing ASP.NET Web Forms site I'm in the process of upgrading to an ASP.NET MVC4 Web Application.</p>
  <p>It looks like it should be possible to use my existing membership database with the <code>SimpleMembershipProvider</code> that MVC4 web apps use by default.</p>
  <p>The problem is that the SimpleMembershipProvider expects the <code>UserId</code> column to be of type <code>int</code>, while my existing database uses a <code>guid</code>.</p>
  <p>Here's the relevant portion of my <code>web.config</code>:</p>
  <pre><code>&lt;membership defaultProvider=&quot;SqlMembershipProvider&quot;&gt;
    &lt;providers&gt;
      &lt;remove name=&quot;SqlMembershipProvider&quot;/&gt;
      &lt;add
        name=&quot;SqlMembershipProvider&quot;
        connectionStringName=&quot;LocalSqlServer&quot;
        enablePasswordRetrieval=&quot;false&quot;
        enablePasswordReset=&quot;true&quot;
        requiresQuestionAndAnswer=&quot;false&quot;
        requiresUniqueEmail=&quot;false&quot;
        passwordFormat=&quot;Hashed&quot;
        applicationName=&quot;/&quot;
        maxInvalidPasswordAttempts=&quot;10&quot;
        minRequiredPasswordLength=&quot;1&quot;
        minRequiredNonalphanumericCharacters=&quot;0&quot;
        passwordAttemptWindow=&quot;10&quot;
        passwordStrengthRegularExpression=&quot;&quot;
        type=&quot;WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData&quot;/&gt;
    &lt;/providers&gt;
  &lt;/membership&gt;
  </code></pre>
  <p>Attempting to change the password, for example, I get a <code>RuntimeBinderException</code>:</p>
  <blockquote>
  <p>&quot;Cannot convert type 'System.Guid' to 'int'&quot;.</p>
  </blockquote>
  <h3><em>My primary question is:</em> Ideally, I'd like to keep my existing database intact, and configure the MVC web app to work with it. How can I configure my MVC4 web app to use my existing database (with <code>GUID</code> <code>UserId</code>'s) as the membership database?</h3>
  <p>As a secondary question: I suppose I could change the <code>UserId</code> column to <code>int</code>; does anybody foresee any problems with that, or know the best way to go about that?</p>
  <hr />
  <p><em>This was the best lead I could find on using a <code>UserId</code> of type <code>GUID</code>: <a href="http://aspnet.uservoice.com/forums/41201-asp-net-mvc/suggestions/3573751-use-generic-types-for-userid-in-simple-membership-" rel="nofollow noreferrer">http://aspnet.uservoice.com/forums/41201-asp-net-mvc/suggestions/3573751-use-generic-types-for-userid-in-simple-membership-</a></em></p>