Steffi
Steffi

Reputation: 7057

String in Unique Key in Entity Framework

Is it possible to put a string in Unique Key ?

    public int ID{ get; set; }

    public string TweetID { get; set; }

Because I need ID in primary key (it's ok) and TweetID in unique key (for no duplication in database)

EDIT : I use Entity Framework 4 and MVC3

Upvotes: 0

Views: 677

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364269

It is possible to define unique key on string column but you must do it in the database (as unique index) because none of current EF versions support unique keys.

Upvotes: 1

Related Questions