Entity Framework Predesign Views

I added pre-generated views for my model, as described here:

http://blogs.msdn.com/b/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx

Everything seems to work in terms of compiling and generating code, but I'm not sure if EF really uses my pre-generated views since the first ObjectQuery object still takes 3-4 seconds to execute (before generating SQL).

How can I be sure that EF uses pre-generated views?

+4
source share
1 answer

I have the same problem, but I figured it out: you can set a breakpoint in the constructor of the generated view class. He will be amazed. You can also set a breakpoint in one of the GetViewx () methods. It will be deleted when querying the corresponding table.

I use POCOs that are in a different project / assembly than the generated context. The generated views are in the same assembly as the context. At first I, although this also did not suffer, so I searched and looked for a way to connect them. The best I got is to use the ObjectContext.MetadataWorkspace.LoadFromAssembly (...) method. But breakpoints still hit even when I don't explicitly hook the assembly (I just found this).

Am I really 100% sure that the generated views are being used? No, since I also have a slight delay with a rather small model. But honestly? Yes, as far as I can see.

+2
source

Source: https://habr.com/ru/post/1396883/


All Articles