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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -