How to pre-compile my EF Views

asp.net-mvc-4 entity-framework entity-framework-6

Question

Here is the narrative: I already upgraded MVC 2 to MVC 4, EF4 to EF6, and.NET Framework 4.5 from my large MVC 2 website that used Entity Framework 4.0.

On a project with over 300 entities and 150 controllers, I did that.

The project is currently moving along, though not as quickly as I had anticipated.

I'm using EF 5.x DBContext Generator T4 and Entity Framework 6.0.2. Because I utilized Database First with EF4, I used the DB Context generator.

In the past, I pre-compiled my views using this command line.

"%windir%\Microsoft.NET\Framework\v4.0.30319\EdmGen.exe" /nologo /language:CSharp /mode:ViewGeneration "/inssdl:$(TargetDir)Models/DBModel.ssdl" "/incsdl:$(TargetDir)Models/DBModel.csdl" "/inmsl:$(TargetDir)Models/DBModel.msl" "/outviews:$(ProjectDir)Models/DBModel.Views.cs"

XCOPY "$(TargetDir)Models/DBModel.csdl" "$(ProjectDir)" /R /Y XCOPY "$(TargetDir)Models/DBModel.ssdl" "$(ProjectDir)" /R /Y XCOPY "$(TargetDir)Models/DBModel.msl" "$(ProjectDir)" /R /Y XCOPY "$(TargetDir)Models/SiteWeb.csdl" "$(ProjectDir)" /R /Y XCOPY "$(TargetDir)Models/SiteWeb.ssdl" "$(ProjectDir)" /R /Y XCOPY "$(TargetDir)Models/SiteWeb.msl" "$(ProjectDir)" /R /Y

How do I accomplish the same task with EF6 now?

1
0
10/2/2017 9:51:22 AM

Accepted Answer

EdmGen cannot be used to create views for EF6. Using PowerTools is one option. I also developed a number of T4 formats for generating views and among them for EF6 (both of which are available on the VS Gallery). Considering that the EF6 one is aimed at CodeFirst, I'm not sure how useful it will be for you. Last but not least, I recently released a package on NuGet that enables creating views instantly and saving them for later. For more information, check this.

btw. Using the 5.x DBContext generator with EF6 feels inappropriate. I'm not sure why you use the version for EF5 as the EF Tooling that comes with VS2013 (and a independent version version that is available for VS2012) uses EF6 templates to produce the code (and am kind of wondering how it even compiles given this)

1
12/23/2013 10:24:58 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow