I am new to Entity Framework, I am able to add the .edmx
file and then it would autogenerate the objects but I do not see the .tt
files as shown in the tutorials appearing anywhere this is how it looks
我是Entity Framework的新手,我能够添加.edmx文件,然后它会自动生成对象,但是我没有看到教程中显示的.tt文件出现在它看起来如何
I am not sure what I am doing wrong, but I do not see anywhere in the code things like DbSet
, or anything like that.
我不确定我做错了什么,但我没有在代码中看到像DbSet这样的东西,或类似的东西。
Would appreciate any help.
非常感谢任何帮助。
NOTE : This is database first
1 个解决方案
#1
0
The code generation strategy was changed post-RC. VS 2012 Beta and RC versions used code generation strategy that was used in previous versions of Visual Studio. They did not expose T4 templates and generated ObjectContext based contex and EntityObject based entities. Post VS 2012 RC code generation was changed to generate DbContext based context and POCO entities - all using T4 templates. The tutorials are using VS2012 RTM version and therefore you see T4 templates and POCO entities. You either need to use VS2012 RTM (preferred) or EF5 code generator you can get from VS gallery - http://visualstudiogallery.msdn.microsoft.com/da740968-02f9-42a9-9ee4-1a9a06d896a2. The VS gallery page contains links to some blog posts showing how to replace the code generation strategy used by your project.
代码生成策略在RC之后发生了变化。 VS 2012 Beta和RC版本使用了以前版本的Visual Studio中使用的代码生成策略。他们没有暴露T4模板并生成基于ObjectContext的contex和基于EntityObject的实体。发布VS 2012 RC代码生成后,生成基于DbContext的上下文和POCO实体 - 全部使用T4模板。教程使用VS2012 RTM版本,因此您可以看到T4模板和POCO实体。您需要使用VS2012 RTM(首选)或EF5代码生成器,您可以从VS库中获取 - http://visualstudiogallery.msdn.microsoft.com/da740968-02f9-42a9-9ee4-1a9a06d896a2。 VS库页面包含一些博客文章的链接,其中显示了如何替换项目使用的代码生成策略。
#1
0
The code generation strategy was changed post-RC. VS 2012 Beta and RC versions used code generation strategy that was used in previous versions of Visual Studio. They did not expose T4 templates and generated ObjectContext based contex and EntityObject based entities. Post VS 2012 RC code generation was changed to generate DbContext based context and POCO entities - all using T4 templates. The tutorials are using VS2012 RTM version and therefore you see T4 templates and POCO entities. You either need to use VS2012 RTM (preferred) or EF5 code generator you can get from VS gallery - http://visualstudiogallery.msdn.microsoft.com/da740968-02f9-42a9-9ee4-1a9a06d896a2. The VS gallery page contains links to some blog posts showing how to replace the code generation strategy used by your project.
代码生成策略在RC之后发生了变化。 VS 2012 Beta和RC版本使用了以前版本的Visual Studio中使用的代码生成策略。他们没有暴露T4模板并生成基于ObjectContext的contex和基于EntityObject的实体。发布VS 2012 RC代码生成后,生成基于DbContext的上下文和POCO实体 - 全部使用T4模板。教程使用VS2012 RTM版本,因此您可以看到T4模板和POCO实体。您需要使用VS2012 RTM(首选)或EF5代码生成器,您可以从VS库中获取 - http://visualstudiogallery.msdn.microsoft.com/da740968-02f9-42a9-9ee4-1a9a06d896a2。 VS库页面包含一些博客文章的链接,其中显示了如何替换项目使用的代码生成策略。