Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP .Net Entity Framework .tt Files Not Nesting Under .edmx

I'm running an ASP .NET (v4.5) Web Site Project under VS 2012 Update 2. When I create a new entity model (.edmx) under the App_Code folder, nested under the .edmx file is only the .Designer.cs and the .edmx.diagram files. The associated .tt files are not nested. I think this is why, when I save the model, the T4 templates are not automatically transformed, even though that option is specified in the model properties.

Any ideas how to get this working? I cannot use the DependentUpon XML tag in a project file, since Web Site Projects do not have project files.

like image 359
Erich Peterson Avatar asked Apr 29 '13 02:04

Erich Peterson


People also ask

What file types can .edmx hold?

An . edmx file is an XML file that defines an Entity Data Model (EDM), describes the target database schema, and defines the mapping between the EDM and the database. An . edmx file also contains information that is used by the ADO.NET Entity Data Model Designer (Entity Designer) to render a model graphically.

How do I insert a table into a .edmx file?

Open the edmx file. Right Click anywhere but the tables or relationships. Select "Update Model from Database". Then select 'tables' checkbox in the next dialog box that appears after it has retrieved the data from the underlying database.

How do I regenerate EDMX?

There is no automatically refresh the EDMX (it will be nice from MS if they implement that at some point) and the best and most accurate way to refresh the EDMX is by deleting all tables in the Diagram and then deleting all complex types etc. in the Model Browser.

Does EF core support EDMX?

EF Core does not support the EDMX file format for models. The best option to port these models, is to generate a new code-based model from the database for your application.


2 Answers

Open the .tt file and choose save. This runs the T4 template.

like image 168
Moe Avatar answered Nov 10 '22 22:11

Moe


Web Site does not support Nested Project Files, whereas Web Applications support it.I highly you suggest to use a Web Application.

The only way that I found in past is to Run Manually T4 (Right Click on a TT File) or use a pre build event to run T4.

like image 44
Cybermaxs Avatar answered Nov 10 '22 21:11

Cybermaxs