c# - Entity Framework IsUnique and accept Nulls -



c# - Entity Framework IsUnique and accept Nulls -

how can create code first property accepts null values it's [index(isunique=true)]?

for example: passport number should't repeated, ergo isunique, if user doesn't insert one, defaults null, accepts multiple nulls.

since not unique then, cannot way. can manage it, attaching table:

public class person { public int id { get; set; } } public class passport { [key] public int personid { get; set; } [foreignkey("personid")] public person person { get; set; } [index(isunique=true)] public string passportid { get; set; } }

be aware, there countries, not allow storing such numbers.

c# entity-framework

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -