0

I used hints from stack with modelBuilder entity, but this solution doesn't work for me. Error is raised when i run select on CST_Parameter.

My entity:

 public partial class TargettyMetaEntities : DbContext
{
    public TargettyMetaEntities()
        : base("name=TargettyMetaEntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<CST_Parameter>().ToTable("CST_Parameter");
    }
}

My class:

public partial class CST_Parameter
{
    public int Parameter_SK { get; set; }
    public int Customer_SK { get; set; }
    public string Parameter_ID { get; set; }
    public string ParameterValue { get; set; }
    public bool Active { get; set; }
    public System.DateTime Created { get; set; }
}

Here is the problem:

 public static List<Models.CST_Parameter> GetParameterByName(int customerId, string parameterName)
    {

        using (var db = new Models.TargettyMetaEntities()) //Exception unhandled 
        {

            var par = from p in db.CST_Parameter 
                      where p.Customer_SK == customerId && p.Parameter_ID == parameterName
                      select p;

            return par.ToList<Models.CST_Parameter>();
        }
    }
  • Does this answer your question? [The entity type is not part of the model for the current context](https://stackoverflow.com/questions/20688922/the-entity-type-type-is-not-part-of-the-model-for-the-current-context) – Vivek Nuna Jun 08 '20 at 07:27
  • This solution i was tryed. Is in the code. My Entity: – marek heczko Jun 08 '20 at 07:33

0 Answers0