3

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

8
  • 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. Commented May 28, 2018 at 7:57
  • @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; Commented May 28, 2018 at 7:59
  • Perhaps try as @RistoM suggests - [System.ComponentModel.DataAnnotations.Table] :) Commented May 28, 2018 at 8:03
  • @DavidHruška, tried....not working Commented May 28, 2018 at 8:04
  • 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. Commented May 28, 2018 at 8:14

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.