.Net – Entity Framework – Error – “Error CS1070: The type name ‘TableAttribute’ could not be found. This type has been forwarded to assembly ‘System.ComponentModel.DataAnnotations’

Background

A quick follow up to our last post on adding annotations to our plain old C# class ( POCO).

Lineage

  1. .Net – Entity Framework – error CS0246: The type or namespace name ‘DatabaseGenerated’ could not be found
    Link

 

Error

Error Text


error CS1070: The type name 'DatabaseGeneratedAttribute' could not be found. This type has been forwarded to assembly
'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.

error CS0246: The type or namespace name 'Key' could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'KeyAttribute' could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'Column' could not be found (are you missing a using directive or an assembly reference?)

error CS1070: The type name 'ColumnAttribute' could not be found. This type has been forwarded to assembly 'System.ComponentModel.DataAnnotations,Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.

error CS0246: The type or namespace name 'Table' could not be found (are you missing a using directive or an assembly reference?)

error CS1070: The type name 'TableAttribute' could not be found. This type has been forwarded to assembly 'System.ComponentModel.DataAnnotations,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.

Error Image

CS1070.01.20191119.0303AM

Remediation

Outline

Please be sure to add System.ComponentModel.DataAnnotations.dll to the list of referenced assemblies.

Namespaces Referenced

Here are the namespaces referenced in the Source Code.

  1. System.Collections.Generic
  2. System.Linq
  3. System.Web
  4. System.Data.Entity
  5. System.Data.Entity.Core
  6. System.ComponentModel.DataAnnotations;
  7. System.ComponentModel.DataAnnotations.Schema;

Assemblies Referenced

Here are the assembles (*.dlls) referenced during compilation :-

  1. System.dll
  2. System.Data.dll
  3. System.IO.dll
  4. C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\WPF\
    • WindowsBase.dll
  5. C:\Program Files (x86)\Microsoft Visual Studio\Shared\Packages\EntityFramework.6.1.3\lib\net45
    • EntityFramework.dll
    • EntityFramework.SqlServer.dll
  6. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\
    • System.ComponentModel.DataAnnotations.dll

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s