Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Issue: [RTM] T4 templates and Legacy Object Context code gen strategy enabled when creating an EF6 model from the database if the project is targeting .NET Framework 4 [1561]

$
0
0
If the project is targeting .NET Framework 4 and the user selects EF6 when creating a new model from the database we will add T4 templates but will also set the Legacy Object Context code gen strategy. This results in creating two sets of entities that conflicts with each other. In addition the Code Generation strategy cannot be changed to T4 (the dropdown is disabled).
Comments: Fixed with changeset# 921c7b3 in the designer repo TooMuchCodeWillKillYouEveryTime (fixes #1561: T4 templates and Legacy Object Context code gen strategy enabled when creating an EF6 model from the database if the project is targeting .NET Framework 4) The issue: When generating an EF6 model from the database in a project targeting .NET Framework 4 which did not have any references to Entity Framework we would both add T4 templates and generate the code using the SingleFileGenerator. This would result in creating duplicate sets of entities (POCOs and EntityObject based) which led to many compilation errors. The underlying issue was that in this scenario we first create a model which is v2 (since the project targets .NET Framework 4 and does not reference any Entity Framework assembly), then we add the EF6 assembly which makes the v2 model invalid and therefore we need to update the model to v3 and reload it to avoid watermark. Before reloading we set the code generation strategy setting in the model correctly but we don't save the changes. Reloading does not save the model either (even if it is marked as dirty) so we end up losing the setting. The fix: Before we would reload the model first and then save it. Now we save the edmx first and then reload (if needed). This way we won't lose the setting and will generate code using only T4.

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>