Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I've got a project and I've setup the Entity Framework model in a folder called App_code.

I've previously added 5 classes (tables) with no problem, but when I try and add the PostCodesUK and then compile I get this error:

VB
Error   1   The type or namespace name 'PostCodesUK' could not be found (are you missing a using directive or an assembly reference?)   d:\Ben\documents\visual studio 2013\Projects\DogWalks\DogWalks\App_Code\WalksModel.Context.cs   32  30  DogWalks


I can't seem to this what the issue is. I look under WalksModel.edmx > WalksModel.tt and I can see the class PostCodesUK.cs. However, this class doesn't have any nodes, unlike the ALL the others, where I can expand the node and see their properties.

The other thing is if I look in the WalksModel.Context.cs I can see:

C#
namespace DogWalks.App_Code
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;

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

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
        public virtual DbSet<Comment> Comments { get; set; }
        public virtual DbSet<DogWalk> DogWalks { get; set; }
        public virtual DbSet<Feature> Features { get; set; }
        public virtual DbSet<Image> Images { get; set; }
        public virtual DbSet<Rating> Ratings { get; set; }
        public virtual DbSet<PostCodesUK> PostCodesUKs { get; set; } //error here
    }
}


However, where it says DbSet<postcodesuk>, the PostCodesUK is underlined with the same error message above.

What is happening here, what is the problem? Please help, thanks.

Here is the PostCodesUK class, which looks identical to all other classes:

C#
namespace DogWalks.App_Code
{
    using System;
    using System.Collections.Generic;

    public partial class PostCodesUK
    {
        public int PostcodeID { get; set; }
        public string Postcode { get; set; }
        public decimal Latitude { get; set; }
        public decimal Longitude { get; set; }
        public string PostcodeNoSpace { get; set; }
    }
}
Posted
Updated 8-Nov-15 23:03pm
v2
Comments
Duncan Edwards Jones 4-Nov-15 10:16am    
Does the menu "Build -> Transform All T4 Templates" do any magic for you?
Member 12063314 4-Nov-15 10:21am    
Just tried it and unfortunately the error stays:
Transforming templates for all project items.
-------------------------------------
Transforming template WalksModel.Context.tt with TextTemplatingFileGenerator ... succeeded.
Transforming template WalksModel.tt with TextTemplatingFileGenerator ... succeeded.
-------------------------------------
Text templating transformation complete.
Krunal Rohit 4-Nov-15 11:33am    
Try updating the EDMX form DB.

-KR
Member 12063314 9-Nov-15 5:02am    
thanks for the input, I've just tried updating model (multiple times) and I still get the same error message afterwards. Any other recommendation?

1 solution

Managed to solve it with the solution posted here!
 
Share this answer
 
v2

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