title: Relax or disable table constraints when using Dapper and Entity Framework?
body: <p>I would like to set a do something like this <code>dataSet1.EnforceConstraints = false;</code> using the Dapper.Net ORM and Entity Framework.</p>
  
  <p>I created the models in VS2010 where a property:</p>
  
  <pre><code>    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
      [DataMemberAttribute()]
      public global::System.String ethnicname
      {
          get
          {
              return _ethnicname;
          }
          set
          {
              OnethnicnameChanging(value);
              ReportPropertyChanging("ethnicname");
              _ethnicname = StructuralObject.SetValidValue(value, false);
              ReportPropertyChanged("ethnicname");
              OnethnicnameChanged();
          }
      }
  </code></pre>
  
  <p>... when <code>value</code> is <code>null</code>, I get a constraint exception at <code>StructuralObject.SetValidValue...</code> .  How and where do I turn this off?</p>
  
  <p>My data call looks like this:</p>
  
  <pre><code>    public DAL.Models.PROFILE GetProfile(int profileID)
      {
          using (IDbConnection connection = OpenConnection("MyDBConnectionString"))
          {
              try
              {
  
                  var profiles = connection.Query&lt;DAL.Models.PROFILE&gt;("SELECT * FROM PROFILES WHERE ID=@ID", new { ID = profileID }); // IEnumerable
                  var profile = profiles.First&lt;DAL.Models.PROFILE&gt;();
  
                  return profile;
              }
              catch (Exception ex)
              {
                  ErrorLogging.Instance.Fatal(ex);
                  return null;
              }
          }
      }
  </code></pre>