I got a code first EF and I want to use native sql for the more complex select statements. When I try to execute:
using (VaultsDbContext db = new VaultsDbContext())
{
var contracts = db.Contracts.SqlQuery("select * from Contracts").ToList<Contract>();
}
I got:
Cannot create a value for property 'MetaProps' of type 'DskVault.Models.DbModels.MetaProps'. Only properties of primitive or enumeration types are supported.
MetaProps is a class that holds deleteflag, creator etc. and it's a property of all my classes. It's not mapped to a different table, every table has deleteflag, createor, etc.
public class Contract
{
public long Id { get; set; }
...
public MetaProps MetaProps { get; set; }
}
Is there a way to map from the native sql to the class if the class contains a complex type or does EF not support that? Also what if the complex type is entity mapped to another table(join)?
Edit: Version: Entity Framework 6
MetaPropswhy don't you create a table for it instead of adding those columns to all the tables that need this. Isn't what the RDB is for?