1
votes

I have an MVC5 application running on .NET framework 4.7.1 in VS2017.

When I build my application, I am getting below error. Any suggestions as to how to resolve this issue?

The type 'TableAttribute' 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'

Attribute error

project references

project references

project references

1
You should explicitly express which of those TableAttributes you are using by i.e following way : [System.ComponentModel.DataAnnotations.Table] or by defining using-clauses correctly.Risto M
@RistoM This is my using classes that I've added. using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema;LeoNegi
Perhaps try as @RistoM suggests - [System.ComponentModel.DataAnnotations.Table] :)David Hruška
@DavidHruška, tried....not workingLeoNegi
Can you put screenshot of the Code line where this error happens? As others have said - the error is that [Table] attribute is defined in more than one Namespaces that are used in the code. And hence its causing some error.Prateek Shrivastava

1 Answers

3
votes

Remove "System.ComponentModel.DataAnnotations" from References list Remove all attribute used by dataannotations like [Key],[StringLength].. also run

PM> update-package -reinstall

enter image description here

enter image description here