Reputation: 79
I am currently building an MVC site using Entity Framework. I have created following class:
using System; using System.Collections.Generic;
using System.Linq; using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
namespace .Models {
public class VehicleTableData
{
[NotMapped]
public Dictionary<string,string> StandardVehicleData { get; set; }
[NotMapped]
public Dictionary<string,string> AdditionalData { get; set; }
} }
However, I would like it to be ignored by Entity Framework as when I try to create a view with it I get the error that there is no valid key.
Upvotes: 0
Views: 253
Reputation: 313
If you have the class defined in your DbContext
with the following line of code:
public DbSet<VehicleTableData> VehicleTableDatas { get; set; }
This will cause Entity Framework to include the class. Once the above line is removed it will not be included.
You could also remove the [NotMapped]
attributes as this would only apply to properties that you would not want saved to the database in a model included in your DbContext
.
Upvotes: 1