Foreign key constraint on null column in MSSQL 2005

Thread is closed for posting
2 posts, 0 answers
  1. James Denning
    James Denning avatar
    24 posts
    Member since:
    Apr 2009

    Posted 17 Nov 2009 Link to this post

    In a forward-mapped schema, is there any way I can get OpenAccess to create foreign key constraint on a columns that allows NULLS? SQL Server 2005 supports this but the only option I can find in OpenAccess is the "Throw an exception ion commit if the field is null" option but this sets the corresponding column to NOT NULL.
    What I need is that the Reference field's datasource is a reference table say for example Countries - and I want the database to enforce the referential integrity for tables where the Country entry is not mandatory.

    I could of course alter the schema post-build but that is painful to maintain and hard to automate.

  2. PetarP
    PetarP avatar
    754 posts

    Posted 18 Nov 2009 Link to this post

    Hello James Denning,

    By default Telerik OpenAccess ORM uses algorithms to decide whether a foreign key constraint makes sense or not. In your case you can use this setting in the backend configuration to manually override our logic:

    This will create your foreign key constraint. The backend configuration should look something similar to this after you have added this setting.
          <backendconfiguration id="mssqlConfiguration" backend="mssql">
    Please let us know if this solution works for you.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top