0

I am getting started with ASP.NET and I have a problem. I created an MVC4 application in the Visual Studio. Then to the Models I added an ADO.NET Entity Data Model with the Database first method. Everything okay until I try to add a new Controller when I get an error message: 'Projectname.Models.Tablename' is not part of specified 'Projectname.Models.Contextname' class and the 'Projectname.Models.Contextname' class could not be modified to add a DbSet<Projectname.Models.Tablename> property to it. What is my mistake?

Here is my generated model:

  public partial class Example
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }

End here is my generated context:

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

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }

        public DbSet<Example> Example { get; set; }
    }
4
  • 1
    If you posted some code showing what you've done you'd greatly help people trying to help you. Apr 9, 2013 at 22:49
  • Try adding the ADO.NET entity data model to the root of the application rather than in a folder. Apr 9, 2013 at 22:55
  • I tried it in the root folder too, but it did not helped. Apr 9, 2013 at 23:17
  • I put the understandable part of the code to the question. Apr 9, 2013 at 23:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.