Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Table Attribute not working with MVC5 and EF6

$
0
0

Hello,

       Having an issue with a project I am working on.  I have a web project and portable classes.  I am using Entity Framework 6, and MVC 5.  Everything was working when I had all the classes in the Web side, but once I moved them to the Portable side, I began to have an issue with the data annotation.  Here is the code from one of the classes:

namespace Inventory.Entities
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    [Table("Common.Location")]
    public class Location
    {
        public Location()
        {
            Assets = new HashSet<Asset>();
        }

        [Key]
        public int LocationID { get; set; }

        [Required]
        [Display(Name = "Location Name")]
        public string LocationName { get; set; }

        public virtual ICollection<Asset> Assets { get; set;}
    }
}

Now the issue is that Table has a red squiggle and I am getting the following error: Error  43  The type or namespace name 'TableAttribute' could not be found (are you missing a using directive or an assembly reference?)

As far as I can tell everything is set up correctly, but this just does not want to work.  It is not only this class, but all of my classes.  The only reference I have in the portable classes is .Net with a target of 4.5.  Everything I read says this should work, but clearly it is not working.  I have also uninstalled and installed the entity framework, did a clean and build but with no luck.  Any thoughts?


Michael R. Mastro II


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>