Print Page | Close Window

[SOLVED]Web Example for EF

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=741
Printed Date: 25-May-2024 at 6:30pm


Topic: [SOLVED]Web Example for EF
Posted By: miltonb
Subject: [SOLVED]Web Example for EF
Date Posted: 24-Mar-2008 at 6:58pm
Hi,
 
Is there an example (or code) of an asp.net web application using EF?
 
I have used the code below from examples in my asp.net app (without static method) but get the error as below.
 
 
        private void RunQuery00()
        {
            MCDomainModel.Manager aManager = new MCDomainModel.Manager();
            var query = aManager.tciUser;
            foreach (MCDomainModel.tciUser aUser in query)
            {
                TextBox1.Text = aUser.familyName + " " + aUser.givenName + "\r\n";
            }
        }
 
Error appears when get to foreach query: The specified metadata path is not valid. A valid path must be either an existing directory, an existing file with extension '.csdl', '.ssdl', or '.msl', or a URI that identifies an embedded resource.
 
Thanks.
 
Milton



Replies:
Posted By: kimj
Date Posted: 25-Mar-2008 at 9:19am
Sorry, we don't have an ASP.NET example yet, and it may be a few more revs before we do.
 
A few things to look at now:
 
1) If you're using "loose" artifact files (the *.csdl, *.msl and *.ssdl files) they should be located in your bin folder, along with the server model assembly. 
 
2) You'll need to tweak the connection string for the EdmKey in the config file so that the metadata points to the bin folder, something like this:
 
connection="metadata=~/bin/MyModel.csdl|~/bin/MyModel.ssdl|~/bin/MyModel.msl; ... <other connection info removed>
 
3) If you're using artifact files embedded in the server assembly, well, first I would say that in EF Beta3 they're more trouble than they're worth so don't bother.  But if you are,  make sure the server assembly is in the bin folder, and change your connection string to something like:
 
connection="metadata=res://MyServerModelAssemblyName;   ... <snipped remainder>


Posted By: miltonb
Date Posted: 25-Mar-2008 at 5:34pm
Thanks for your prompt and accurate reply.
 
I used suggestion 2) with
            <edmKey connection="metadata=D:\Projects\ServerModelMC.csdl|D:\Projects\ServerModelMC.ssdl|D:\Projects\ServerModelMC.msl;
provider=System.Data.SqlClient;provider  etc.......
 
I copied the files into the root of the projects folder.
 
The page is not working, I will now press on.
 
Milton



Print Page | Close Window