onsdag 25 november 2009

UNIQUE constraint on properties in the EDM (EF4)

There is no built in way of accomplishing this. The best way I've found to do this is to:
  1. Modify the database generation workflow, look for annotations in the CSDL and move them to the SSDL. This post by Dan Simmons on the EF-team explains how to do it.
    Modify the T4 that sits behind the SSDL to DDL activity and have it produce a UNIQUE constraint for each field that has been annotaded.
  2. Build an extension to the EF designer / property sheet to allow for annotations to the Entity Properties. An example on how to do this can be found in ADO.NET Entity Data Model Designer Extension Starter Kit.
  3. Annotate the Entities/Properties in you EF Data Model where you want to have a UNIQUE constraint.

Inga kommentarer:

Skicka en kommentar