Unique constraint entity framework

c# entity-framework entity-framework-6 visual-studio-2013

Question

I'm using Entity Framework 6.1.1 together with MS SQL Server 2012. I used the designer to construct a model. I now want to provide an attribute a unique quality. How can I do this while maintaining the model creation using the designer?

I edit using the model-first method.

Many thanks

1
1
1/14/2015 11:11:52 PM

Popular Answer

Study this! You ought to get pointed in the appropriate path by it.

Use of the following code is the idea:

CreateIndex("dbo.Users","Username",true);

that is an EF approach. It's unlikely in the designer, in my opinion.

EDIT

I discovered these words, which claims that (not in the designer, but in code) unique restrictions are achievable.

[Index(IsUnique = true)]
public string EmailAddress { get; set; }
1
5/23/2017 12:10:23 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow