I’ve not been working with EF until this week (v5) and now I’m making a few database changes it’s doing some really weird things.
I deleted an NVARCHAR Country field and replaced that with an CountryId int field that is a Foreign Key to the Id column of the Country table
ALTER TABLE [dbo].[UserProfile] WITH CHECK ADD CONSTRAINT [FK_UserProfile_Countries] FOREIGN KEY([CountryId])
REFERENCES [dbo].[Countries] ([Id])
Updating the model in VS2012 is doing some really unexpecting things. Its reporting an error on the field I removed:
Error 11010: Association End ‘Country’ is not mapped.
And I have two virtual fields added to the model which doesn’t seem correct:
public partial class UserProfile
{
public int UserId { get; set; }
...
public int CountryId { get; set; }
public virtual Country Country { get; set; }
public virtual Country Country1 { get; set; }
}
I’ve read there is a bug with the designer and manually running “Run Custom Tool” on the .tt files fixes this but it doesn’t appear to have worked.
Has anyone seen this or solved it?
Just for the record I’ve burned through so much time on Database First I’m ditching it all and writing code instead …