Link to home
Start Free TrialLog in
Avatar of AidenA
AidenA

asked on

Entity framework: conflicts between edmx designer file and tt files

Hi,

I've just started taking a look at the entity framework but having a load of trouble getting it working so far. When I create the edmx file (.NET 4.5) it creates tt files as well as creating the designer.cs file. I get the feeling this may not have happened in visual studio 2010 and you had to add the tt files separately by using the Add Code Generation Item dialog and adding the DbContext Generator... then that adds the tt files.

Anyway, what I notice is that when I delete these tt files I can build my project, but when these tt files are there, there seems to be a load of naming conflicts... like the tt files are generating duplicate code, so I end up with two identical entities for the same table (if that's how you'd describe it). So, basically I'm wondering what's going on here and how to solve the problem as it seems that the tt files can be of some use but at the same time they are conflicting with the Entity.Designer.cs code?
Avatar of Andr3wC
Andr3wC
Flag of Ireland image

Hi,

That is correct you normally add the tt file manually after the creation of your edmx file.

Check out the below tutorial on creating your Entity Framework, it steps you through creating your edmx file as well as going through the creation of the tt files also.

http://entityframeworktutorial.net/create-first-simple-EDM.aspx
Avatar of AidenA
AidenA

ASKER

Hi thanks,

Sorry so busy it was hard to find time to get back to this.

I understand that people use tt files, but the problem I'm having is that when Visual Studio 2012 creates the edmx files, it automatically creates the tt files too. The problem is that these seem to conflict with one another as I mention. There is some duplication of code between them. Only when I delete the tt files can I run the program and the errors go away
ASKER CERTIFIED SOLUTION
Avatar of Andr3wC
Andr3wC
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AidenA

ASKER

Hi thanks,

not sure if that's the issue since the problem occurs straight away and not just when i'm updating stuff, but might be worth watching out for that issue anyway...

actually haven't got time to look at this again until later next week so i'll just accept this now and check into it again then
Great, no problem thanks for the points.