Entity Framework 6 where did key and column attributes go

c# ef-code-first entity-framework entity-framework-6 entity-framework-6.1


I'm upgrading from Entity Framework to Entity Framework 6 and I'm having a really hard time tracking where all of the old classes went and what namespace things are in these days.

I've got a class that looks like this and was using these attributes but now I

[Key, Column(Order = 1)]
public int PersonID { get; set; }
[Key, Column(Order = 2)]
public int WorkoutID { get; set; }
  1. Can't figure out what namespace the attributes are in
  2. Even figure out if I'm supposed to be using them
  3. Can't nuke the EF class lib and rebuild it because the DB is code-first - I think..
    1. Disclaimer: I've never really worked from code-first because I like being able to rebuild my edmx file from scratch

Can anyone point me in the right direction? MSDN docs have some up short, the EF 6 upgrade guide (found here: http://visualstudiomagazine.com/articles/2014/03/01/whats-new-in-entity-framework-6.aspx) doesn't contain what I need and you'll all my last hope (not really - I'll keep looking no matter what)

7/25/2014 12:41:31 AM

Accepted Answer

I am not sure that I understand your question, but all of EF6 CF attributes are in : System.ComponentModel.DataAnnotations

you can find more here:

System.ComponentModel.DataAnnotations Namespace ()

7/25/2014 3:32:32 AM

Popular Answer

The attributes dealing with database schema moved to: System.ComponentModel.DataAnnotations.Schema Namespace.

That's why they may appear missing when you upgraded, but just adding that namespace to your code file will get things back working.

Related Questions


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