EntityFramework CF and Pre-Generate Views - entity-framework

I want to reduce startup-time by using Pre-Generate Views as described on the following link: http://msdn.microsoft.com/en-us/library/bb896240.aspx
Can I use Pre-Generate Views in Code First approach and how?
Any help would be greatly appreciated.

EF Power Tools CTP1 contain feature called Optimize Entity Data Model which should be equivalent to pre-generating views for EDMX.

Unfortunately you can not use them in Code First.

looks like Pre-generated views are not supported by Code First (no precompiled queries in EF http://blogs.msdn.com/b/adonet/archive/2011/03/02/ef-4-1-is-coming-dbcontext-api-amp-code-first-rtw.aspx ).
Here you can find some performance tips for EF : http://msdn.microsoft.com/en-us/library/cc853327.aspx
You can however reverse your DbContext and extract the EDMX using the EF Power Tools, once done that you can tune your queries.

EF Power Tools Beta 3 includes pre-generating views for Code First, as you can see at the bottom of this blog post
EF Power Tools Beta 3 Available
You can download this tool from Visual Studio Gallery

Related

Is there any fastest method to update edmx?

I am using Sqlserver 2008 . I want to generate or update edmx. it take 8-15 minute to generate edmx. is there is any tool to create edmx fast?
I have a tool that works with VS2008, VS2010, VS2012, and VS2013, that can do both full and incremental updates of EDMX files. It doesn't work with VS2015 though, as development has been on ice for a while, and VS2015 don't support the same integration interfaces as previous versions of Visual Studio.
You can download it from https://huagati.com/edmxtools/ (free nowadays), and there's a screencast showing the functionality I think you are looking for at https://www.youtube.com/watch?v=doqYOlcEAZM
I don't know any way to generate EDMX model besides the "Update Model from database" approach. However, from my own experience, if your model is too big, you have 2 options:
Split your current model into several parts (Microsoft recommends 50 entities per model); or
Use Code-First instead of EDMX
Hope it helps!

Entity Framework Powertools - Code First Generate Views On Build

Right now Power Tools Beta 4 provides generation of views with a right click. This is fine as far as it goes but can cause issues because you have to remember to do it.
Is there any way that I can make it do the generation of views at compile time? (i.e. some sort of pre-build action or something?
Thanks!
You can use T4 templates for generating views I created a while ago. Take a look here for the EF5 version and here for the EF6 version. You will need to do some MSBuild work to make the T4 template run on Build. You can take a look at comments for this blog post where this is discussed a little bit.
EDIT
I also recently published Interactive Views for EF6 on NuGet so now you can have pre-generated views without having to generate them at the build time.

Entity Framework Pre-Generated View on Assembly

I just started using EF 6 and I noticed that the first execution takes more time because it needs to be compiled, so I researched and found that you can pre-generate the view.
I used EF Power Tool to generate the view: http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d/
It's a dll, and I'm building using the option Embed in Output Assembly.
The problem is that even though I have the view.cs when I execute the first query I have the same delay, so it seems that my library is not using the pre-generated view.
What could be wrong? I'm passing the connection to the entity using an EntityConnectionStringBuilder returning a EntityConnection object.
Also I tried changing the view.cs to Embedded Resource, since with Compile I did not have any changes, in both ways I still have the first time delay.
I'm sure I'm missing something, but not sure what.
Thanks in advance,
Lucas.
EF5 views will not work with EF6 (in addition to that there are some issues with EF6 Beta 1 and EF6 RC1 which prevent using views with EF6 - these issues should be fixed for EF6 RTM). I created a T4 template for generating views for EF6 - you can find more details here - again due to the problems above the views generated by the template will not work for EF6 RC1. If you absolutely think you need it you can try the version from my github - it was updated to work with EF6 RTM and also works with nightly builds.
Anyways, I am pretty sure that this is actually not view generation that are causing the issues (actually the performance of view generation in EF6 has been greatly improved). We recently found a few performance issues (see 1674 and 1662) that are affecting start up time and we are looking at these.
EDIT
The version of the template that works with EF6 RTM (6.0.0.0, 6.0.1.0) has been published to the VS Gallery

Data sources toolbox for VS2012 does not display my entity model

After adding an entity model either from the datasources toolbox itself or by adding it => "add" => "new item" it does not show up in the datasources toolbox and therefor i dont get that easy drop and drag functionality.
If I add a dataset it works but that is an older technology (is it not?) everything in my current project are entity models and to change to datasets (which only works if I add xmlns:yourAlias="clr-namespace:WpfApplication3") would be .. I don't think best practice and a waste of time.
I have recreated this same process of adding a entity model in VS 2010 and it works 100%, where i have the ability to simply drop and drag from the dataSource toolbox
Maybe ill just wait for VS SP1 before working with it for client projects. :(
//Edit
If I add the ADO.net Entity model in VS2010 and then load the project in 2012 it loads fine in the dataSource toolbox. This is an answer but not an ideal work around.
While working on a project I recently faced the same problem. It took me about two days of extensive research but I think I've finally found it:
http://msdn.microsoft.com/en-us/data/jj556581
At least for me it solved the problem. Please let me know if it helped you..
Being addicted to L2S, I tried to get familiar with VS2012 and EF5. But I nearly lost my nerves trying to use the data sources toolbox.
Finally I found a solution:
using Object Data Source is now the recommended approach for using EF in databinding scenarios. See this article for more details - http://msdn.microsoft.com/en-us/data/jj574514. The article also includes a link to revert to the old code generation if that is what you desire.

Entity framework Code First simple wpf/winforms repository layered example

Looking for the simple layered example that uses code first and repository, with either winforms or WPF (no ASP.NET).
I did not realize it is such an unusual question. Does anybody know of any example? I would like to use entity framework code first in layered project, but all samples I could find use ASP.NET (not familiar with), or use .edmx file, or are a simple console project. I can not connect the dots on how to actually make it work, and simple example would really help.
You can start by this one, EF Code First and WPF with the Chinook database
Follow it up by this ONE