How do I not map a Class with the Entity Framework

1

I'm doing my first system (C # ASP MVC 5) with the Entity Framework and Migrations.

I have my classes that have been correctly mapped and migrated to the Database that is SQL Server 2012.

But the question is how can I create a class that is not mapped by EF and Migrations?

I have a Certificate class as below:

In this class I create a StatusCertificate field, for this I thought of creating a class to be an enum data type, but EF insists on creating this class / table in my database. This Enum would only have the values (Active, Inactive, Overdue).

I think then that I do not need to create a physical table in the bank.

How can I do this? Thanks in advance.

using System;
using System.ComponentModel.DataAnnotations;

namespace ControleGCD.Models
{
    public class Certificado
    {

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

        public string CertificadoChave { get; set; }

        public string CertificadoDescricao { get; set; }

        public decimal CertificadoPreco { get; set; }

        public DateTime CertificadoDtCompra { get; set; }

        public DateTime CertificadoDtVencimento { get; set; }

        public DateTime CertificadoDtCadastro { get; set; }

       **public DateTime CertificadoStatus{ get; set; }**

    }
}
    
asked by anonymous 18.06.2018 / 14:49

1 answer

2

You can use the DataAnnotation [NotMapped]

namespace ControleGCD.Models
{
    public class Certificado
    {
        //...
        public DateTime CertificadoDtCadastro { get; set; }

        [NotMapped]
        public DateTime CertificadoStatus{ get; set; }
    }  
}
    
18.06.2018 / 15:08