Strange one, I've already added 5 tables with no problem. However, when I try and add my PostCodesUK table through my edmx model, it gives me this error message:
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 33 30 DogWalks
Not sure what is happening but there are some subtle differences. For example, if I look under the WalksModel.tt classes, I can see the PostCodesUK class, but it hasn't generated the additional 'stub':

If I then double click the error above, it takes me to the WalksModel.Context.cs where I see this error:

I've looked at the namespace under the PostCodesUK.cs class, which matches the other classes. Does anyone know what the issue is? I have searched online for the issue but could not find a solution.
Update: This is what the PostCodeUK class looks like:
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; }
}
}
Furthermore, I've added another temporary table (Person) to my model to test it and it's also giving me the same error message as PostCodesUK:
public virtual DbSet<Comment> Comments { get; set; }
...
public virtual DbSet<PostCodesUK> PostCodesUKs { get; set; } //error
public virtual DbSet<Person> People { get; set; } //error
Ok after spending countless hours trying to find a solution I may have actually solved it (touch-wood).
I got frustrated so I deleted my edmx model. Reading online, I found there was a bug with VS 2012 when the edmx model was saved in a subfolder (not in the root). So this might be something to try if my solution below doesn't work, although I managed to keep it in a subfolder.
Anyway, after deleting my model:
build action for all the classes (From Content to Compile)So to put it to the test I tried:
Person. 
Build Action setting to Compile, saved, closed VS and reopened it and the stub appeared correctly:

I don't know if that was the issue, but it seems to be working. I didn't check my original case but I have a suspicion that I changed the .cs compile mode for my original classes, but not for the newly added classes.
I'm just glad I held off from turning my machine into scrap metal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With