Unique keys in Entity Framework 4

前端 未结 5 689
猫巷女王i
猫巷女王i 2020-11-28 12:13

An existing DB schema has unique, non-primary, keys, and some foreign keys that rely on them.

Is it possible to define unique keys, which are not primary keys, in

5条回答
  •  一整个雨季
    2020-11-28 12:35

    You can use DataAnnotations validation as well.

    I've created this (UniqueAttribute) class, that inherits ValidationAttribute, and when applied to a property, the values of that column will be retrieved and validated against, during validation.

    You can grab the raw code from here.

提交回复
热议问题