Using [ForeignKey ("")] - MVC

2

My domain is as follows

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Dominio
{
    public class Bolsa_AlunoProva
    {
        public int ID { get; set; }
        public int Nota { get; set; }
        public DateTime DataInicial { get; set; }
        public DateTime DataFinal { get; set; }

        public virtual Bolsa_Aluno Aluno { get; set; }

        [ForeignKey("Bolsa_ProvaID")]
        public virtual Bolsa_Prova Prova { get; set; }

    }
}

However, I can not use [ForeignKey("Bolsa_ProvaID")] because it points to a lack of references. However, the required reference is not only System.ComponentModel.DataAnnotations ?

@edit

    
asked by anonymous 10.11.2014 / 20:01

2 answers

2

This annotation only exists for .NET Framework 4.5 and up. Consider changing your application to Framework 4.5.

Teach this in this answer .

More: link

    
10.11.2014 / 20:57
1

The correct using is: System.ComponentModel.DataAnnotations.Schema;

    
10.11.2014 / 20:20