Converting to Web Application Project: EntityFramework/DataAnnotations type exists error

239 views Asked by At

I'm working to convert an old Web Site project to a Web Application Project and I've run into this issue with no help from the compiler as to what I need to look at or possibly change.

Here's the full text of the error: "The type 'ColumnAttribute' exists in both 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'" error

Here's the lines in a cs file that are getting the error (in an entity class):

[Column(TypeName = "ntext")]
[Required]
public string r_roleDescription { get; set; }

The line with "Column(TypeName..." is highlighted with the error.

Any ideas?

2

There are 2 answers

0
Owen On BEST ANSWER

Thanks for the responses. It turns out that the problem was the compiler getting lost because of too many errors. I copied over the files from the website project to the web application project one at a time, fixing errors as they appeared, and this error went away.

Thanks,

0
Connor Low On

Use the full namespace path to specify which you actually want to use:

// If you want the DataAnnotation:
[System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "ntext")]
[Required]
public string r_roleDescription { get; set; }

The compiler just needs you to tell it how to resolve it since there are two possibilities (Entity and ComponentModel).