New Posts New Posts RSS Feed: dbConttext and Precompiled Views
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

dbConttext and Precompiled Views

 Post Reply Post Reply Page  12>
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: dbConttext and Precompiled Views
    Posted: 21-Feb-2014 at 2:24am
forget it. Everything seems to be fine. The Precompiled views are finally working. For some reason, creating a new solution and moving everything over to it seemed to solve the problem. thank you Dennis for all your Dennis and for steering me in the right direction.

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 20-Feb-2014 at 1:52pm
ok i think i found the problem. In my Web application i need to have a reference to my domain model. From my client app i access the remote methods on the server app. I need a reference to the server app. but now i have a reference in my client app to the domain model and to the server app. In my server app i have a reference to the domain model. they both have the UnionData.cdsl, msl, and ssdl files in the domain model. So the app crashes thinking i have a multiple files.

How do i reference the domain model without having a reference to it?

Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 20-Feb-2014 at 11:13am
Sounds like you're on the right track Bill. I'd try creating a fresh Client project and add modules until it breaks.
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 19-Feb-2014 at 9:52am
Ok I am getting closer to solving this. I got the sample application that you sent me to work. I then created a new solution for my application and moved the domain model over to it. I put the lines in the MainWindow_Loaded to access a table in my database and it worked. I then moved my app.config file to the new solution and it still worked. So i have proved the DomainModel is set up correctly and working fine and the configuration file is working fine.

so what else could it be? i put the same MainWindow_Loaded method in my application and it fails. So i has to be something with my Client project. I have no Web project as i got rid of that to make this simpler to figure out.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 18-Feb-2014 at 5:01pm
I did and I was able to verify that it's not failing. I can see in variable 'r' that I'm getting 93 customer records back. Something must be different between your environment and mine.

In any case, I think the best thing to do next is to upload the new simple solution you just created so I can take a look.

Please make sure that you're using NorthwindIB database in order to debug this faster.
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 18-Feb-2014 at 10:01am
you need to put a try and catch in ur solution and you will see it is failing.

  void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var mgr = new NorthwindIBEntities();

                var r = mgr.Customers.ToList();              //fails on this line.
            }
            catch (Exception ex)
            {
                DebugFns.WriteLine(ex.Message);
            }
        }
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2014 at 9:38pm
Ok i downloaded your sample and ran it and the same error. I created a new solutions and a new domain model consisting of  one entity. went through all the steps and got the same error message. i would be glad to upload both yours and mine to show you that it is not working. if i take the precompiled views out, both apps work fine.



Back to Top
JoshO View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Location: United States
Posts: 86
Post Options Post Options   Quote JoshO Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2014 at 5:54pm
Strange, I was able to download the zip without being logged in at all with all major browsers (IE, FF, Chrome). Then I did the same logged in and was successful too. I'm not sure what could be intercepting and forcing a login redirect. Just to see, try logging out and then hit the link.
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2014 at 4:20pm
its redirecting me to a login page.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2014 at 3:44pm
At quick glance, all your steps seem to be correct.

Click on the link below to download my working WPF n-tier sample project. See if you can compare what I have with yours.

I'd also suggest that you create a separate simple solution with your model, similar to what I did here, so we can eliminate other complexities.

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2014 at 1:56pm
Let me tell the steps i have done so far.

1. Modified the UnionData.edmx file i changed the Metadata Artifact Processing property to Copy to Output Director

2. Built the project

3. Added the following to the Pre-Build event command line

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

4. Built the project

5. In my Domain Model I added the 3 files to my project. IUnionData.csdl, UnionData.msl, and UnionData.ssdl and set the Build Action of each to Embedded Resource and the Copy to output directory to do not copy

6. Added the UnionData.Views.cs to the DomainModel

7. Rebuilt the applicaiton

8. Changed my app.config. for now i am only running client server

    <add name="UnionEntities" connectionString="metadata=res://*/DomainModel.UnionData.csdl|res://*/DomainModel.UnionData.ssdl|res://*/DomainModel.UnionData.msl; />

9. Run the app. Same error

An unhandled exception of type 'IdeaBlade.EntityModel.EntityServerException' occurred in IdeaBlade.EntityModel.dll

Additional information: Key 'UnionEntities': The model's metadata artifact files (csdl, msl, ssdl) are either invalid or could not be found, either as resources in an assembly or loose in the output directory.  Perhaps you have multiple assemblies containing the same metadata. Check the connection string for key 'UnionEntities', which says the artifact filenames are UnionData.csdl, UnionData.ssdl, and UnionData.msl. Do these names match the actual artifact filenames? All three root names (e.g., 'UnionData') should be the same and match the edmx filename unless you changed them deliberately.

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2014 at 1:36pm
Tried those additional things and no difference i still get the same error when i run the application. Now i am not using CodeFirst and I dont have the CodeFirst.app dll. Does that matter?

Bill



Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 17-Feb-2014 at 1:06pm
Hi Bill,

You have to add the ssdl, csdl and msl resource files to your DomainModel project and set their Build Action to Embedded Resource. Then in your web.config, (assuming you have an n-tier web project), modify how you're specifying the metadata in your connection string as follows,

Metadata=res://*/DomainModel.Model.csdl|res://*/DomainModel.Model.ssdl|res://*/DomainModel.Model.msl
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 14-Feb-2014 at 6:20pm
do i have to add the 3 data files to the project if i am using the precompiled views? as i said everything works fine if i take the views.cs file out and rebuild

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 14-Feb-2014 at 6:06pm
do i also have put the views.cs in the client project?

Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 14-Feb-2014 at 5:57pm
no it is a WPF app. My DomainModel project is linked on the client.


Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down