Print Page | Close Window

ModelExplorer 2 - Getting lots of errors

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1275
Printed Date: 29-Apr-2025 at 4:49pm


Topic: ModelExplorer 2 - Getting lots of errors
Posted By: BenHayat
Subject: ModelExplorer 2 - Getting lots of errors
Date Posted: 22-May-2009 at 5:46pm
I downloaded the new Source code and after setting the connection string, when I try to build I get 22 errors mostly related to app.config and web.config related to incompatibilities.

Also at runtime I get error 3027.


-------------
Best Regards!
..Ben

WPF & Silverlight Insider
http://www.MicroIntelligence.Com - http://www.MicroIntelligence.Com



Replies:
Posted By: WardBell
Date Posted: 22-May-2009 at 7:23pm
Ok ... let's take it from the top.
 
First, before touching any string of any kind, make sure the solution compiles. Compilation is not dependent upon connection string values. Of course it won't run if they're wrong. But it should compile without errors ... and THAT is step #1.
 
If you unzipped the package and didn't move anything, all files and directories are where they should be.
 
Make sure you've got the DevForce directory (holding the DevForce assemblies). That directory must be a sibling of the ModelExplorer2 directory. You'll know it's missing if the links don't work.
Of course if DevForce is installed, this directory becomes irrelevant ... .NET always looks in the GAC for strongly named assemblies.
Everything should compile before you make any changes whatsoever. There is no point in going forward if you can't get it to compile cleanly.
 
If you've teaked anything, I recommend you unzip again and take it from the top.
 
--
 
After you have a clean compile, you're ready to connect to the database and the web server.
 
Please make sure you've attached the NorthwindEF database if you don't already have it as a result of installing a recent version of DevForce. The database included in the package: as .mdf and .ldf files.
 
--
Everyone else listening: you've installed Silverlight 3, right? This only works with Silverlight 3. If you're not sure, contact us.
--
 
Regarding app.config. Unfortunately, there are a bunch of them scattered among the projects. All but one are irrelevant ... you need them only during model development. They have no effect on runtime. Leave them alone for now.
 
The one that matters at runtime is the one in your Silverlight client project ... ModelExplorer2 in our example. There is no reason to touch this when you're just getting started. I'm assuming you're running with Cassini (the practice web server within Visual Studio), right?
 
--
 
Which brings us to the Web.config in ModelExplorer2Web.
 
There is only one reason to go in there when you're starting out. You might have to change the connection string  to make it work for the way you installed the NorthwindEF database.
 
The string you care about in the web.config is in the <edmkey/>. Here's the whole key.

<edmKey name="Default" connection="metadata=res://ModelExplorer.ServerModelEF/Model1.csdl|res://ModelExplorer.ServerModelEF/Model1.ssdl|res://ModelExplorer.ServerModelEF/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=NorthwindEF;Integrated Security=True;MultipleActiveResultSets=True&quot;" containerName="ModelExplorer.ServerModelEF.NorthwindEFEntities">

The relevant part of this monster is
provider connection string=&quot;Data Source=.;Initial Catalog=NorthwindEF;Integrated Security=True;MultipleActiveResultSets=True&quot;
 
If you can't reach the database with this string you'll need to find the string that works ... and plunk it carefully in there. If it won't compile, chances are you've done what I usually do ... break something in the XML. Grrr.
 
Let us know if you're still stuck.  -- Ward
 
 


Posted By: BenHayat
Date Posted: 22-May-2009 at 8:42pm
Here is how I can reproduce the problem.

I unzip the zip file and do a solution built and everything works fine.
Next step I opened the Model1.edmx file and on the designer I did "Update model from database" to update my connection string by VS.
As soon as I do this and try to built the solution, I get 22 to 27 errors.

With prior explorer template and other samples, I've had no problem updating the edmx Connection string and manually updating the Web.config, now.

The core of this problem seem to be starting from the EDMX



-------------
Best Regards!
..Ben

WPF & Silverlight Insider
http://www.MicroIntelligence.Com - http://www.MicroIntelligence.Com


Posted By: WardBell
Date Posted: 22-May-2009 at 9:18pm
Hmmm.  So far this earns the coveted "Works on My Machine" award.
 
- I build; works great
- I open Model1.edmx (not something you need to do, btw).
- I update model from db; of course this has no affect on my connection string as I was pointing at the db to begin with.
- I build ... no errors ... I run ... like a champion race horse.
 
I don't understand why you are going through the edmx update process. Are you using the EF designer to discover the proper string? I'm kind of lost on this score; there is no functional necessity of invoking EF designer as everything is already aligned.
 
You should not expect the process you described to update the Web.config. If there were a change to the connection string, you'd be putting that manually into the Web.config.
 
One thing that is different than the old ME template and some samples perhaps: I did "the right thing" and broke out the model components into three separate projects, all under the "Model"Visual Studio folder:
 
- ClientModel (DevForce model on the client-side compiled against the Silverlight assemblies)
- ServerModel (DevForce model on the server-side compiled against the .NET assemblies)
- ServerModelEF (Entity Framework model on the server-side compiled against the .NET assemblies)
 
This allocation may be a little over the top; the DevForce and EF models could co-reside. But this seemed nice and clean.
 
In any case, this change should have no adverse consequences.  Looks like I'm going to have to look over your shoulder.
 


Posted By: BenHayat
Date Posted: 22-May-2009 at 9:25pm
I found the problem;

In all previous samples it was recommended to use IB version of Northwind Including ME1 and here it was changed to Std Northwind. So, I was setting the connection string to the IBNorthwind and was getting all errors.

The interesting is that the speed of getting 91 customer from my local machine, is almost as running the live version and getting that data over the wire.


-------------
Best Regards!
..Ben

WPF & Silverlight Insider
http://www.MicroIntelligence.Com - http://www.MicroIntelligence.Com


Posted By: BenHayat
Date Posted: 22-May-2009 at 9:32pm
Originally posted by WardBell

 
I don't understand why you are going through the edmx update process. Are you using the EF designer to discover the proper string? I'm kind of lost on this score; there is no functional necessity of invoking EF designer as everything is already aligned.
 

Ward, thanks for prompt response. As I mentioned in the previous post, the problem was connecting to wrong database. However you raised this question which raises another question. If I go to EF Designer and from the menu I select "Update Database" it always updates the connection string for EF. Well, how and where else can I update that? I've always done it this way?


-------------
Best Regards!
..Ben

WPF & Silverlight Insider
http://www.MicroIntelligence.Com - http://www.MicroIntelligence.Com


Posted By: WardBell
Date Posted: 22-May-2009 at 9:47pm
A VERY IMPORTANT point: the ModelExplorer (and PrismExplorer) target "NorthwindEF" ... a database that comes from the Entity Framework team.
 
I CANNOT warrant that Model Explorer (ME) or Prism Explorer (PE) will work against any other database: certainly not the IdeaBladeTutorial (the database of most DevForce samples) and I don't think it will work with standard Northwind either.
 
If you have built against standard Northwind you may run into trouble somewhere. I confess I hadn't thought to try it; I don't know how it differs from standard Northwind.
 
--
 
Re: How to get a connection string
 
There are many ways to find a working connection string.
One way within Visual Studio that works.:
 
- Launch ServerExplorer
- Open a connection to the db of choice.
- Right-click on the database listed in the ServerExplorer window (assuming you connected safely)
- Ask for "Properties"
 
The connection string is displayed in the Properties window.
 
Note this is only one way to FIND a working connection string. It isn't necessarily the best way and certainly not the only way.
 
When you use the EF designer, you'll find that it updates the string in the App.config in the ModelExplorer.ServerModelEF project. As I mentioned earlier, this App.config has no bearing on the way the application runs; it's an EF design time thing only. Changes here do not propagate anywhere to my knowledge.
 


Posted By: BenHayat
Date Posted: 22-May-2009 at 10:03pm
A VERY IMPORTANT point: the ModelExplorer (and PrismExplorer) target "NorthwindEF" ... a database that comes from the Entity Framework team.


Yes, I meant to say NorthwindEF (Sorry, I left the EF out).
I have both the IB and EF running, but with your samples before I assume it needs IB. "Someone" forgot to make a read.me :-)




-------------
Best Regards!
..Ben

WPF & Silverlight Insider
http://www.MicroIntelligence.Com - http://www.MicroIntelligence.Com



Print Page | Close Window