Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to solve following this problem.

When Create a Controller then error message show below is

VB
Unable to retrive metadata for 'pos.Model.Semester'. Unable to cast objectof type
'System.Data.Entity.Core.Objects.ObjectContext' to type 'System.Data.Objects.ObjectContext'


Model Class is:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace pos.Models
{
    public class Semester
    {
        [Key]
        public int SemesterId { get; set; }

        [Required]
        [MaxLength(30)]
        public string SemesterName { get; set; }
        public int Status { get; set; }
    }
}



Second Class is:

C#
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace pos.Models
{
    public class SemesterContext : DbContext
    {
        public SemesterContext() : base("name=pos") { }
        public DbSet<Semester> Semesters { get; set; }
    }
}




And my Connection String is:

XML
<connectionStrings>
   <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-pos-20150527182631;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />

   <add name="pos" connectionString="Data Source=AZIZ;Initial Catalog=PointofSell;User ID=sa; Password=mdazizulhoque.bd1987" providerName="System.Data.SqlClient" />
  </connectionStrings>



please give me any idea how to solve this error.
Posted
Comments
Jameel VM 28-May-15 13:45pm    
which line you got the error?
azizulhoque.bd 29-May-15 0:56am    
show a popup window Error message
error message is

Unable to retrive metadata for 'pos.Model.Semester'. Unable to cast objectof type
'System.Data.Entity.Core.Objects.ObjectContext' to type 'System.Data.Objects.ObjectContext'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900