locked
System.Data.MetadataException with EntityFramework RRS feed

  • Question

  • Hi all,

     

    I built a very simple project using the entity framework, and I get the following error on my work machine:

     

    ---------------------------

    ---------------------------
    System.Data.MetadataException: 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.

       at System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry)

       at System.Data.EntityClient.EntityConnection.SplitPaths(String paths)

       at System.Data.EntityClient.EntityConnection.CreateMetadataWorkspace(DbConnectionOptions connectionOptions, DbConnection storeConnection, EdmMetadataEntry& edmMetadataEntry, StoreMetadataEntry& storeMetadataEntry)

       at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace()

       at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)

       at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)

       at BmsModel.BmsEntities..ctor() in c:\users\<username>\documents\visual studio 2008\projects\wpfapplication1\wpfapplication1\bmsmodel.designer.cs:line 29

       at WpfApplication1.Window1.Window_Loaded(Object sender, RoutedEventArgs e) in C:\Users\<username>\Documents\Visual Studio 2008\Projects\WpfApplication1\WpfApplication1\Window1.xaml.cs:line 34
    ---------------------------
    OK  
    ---------------------------


    I manage to get it to work on my laptop.

    I checked the add/remove programs dialog and I don't seem to be missing any of the components.

     

    The only difference is that I don't have SQL server locally installed on my work machine and that it's running Vista x64 instead of Vista x86 on my laptop.

     

    I tried reinstalling the "ADO.NET Entity Framework 1.0 (Pre-Release Version)" as well as the "ADO.NET Entity Framework Tools Preview" but it didn't solve my problem.

     

    Can someone help?

     

    Thanks,

    Friday, February 29, 2008 5:07 PM

Answers

  • Sorry for the delay in getting back to you Pierre, I hope you've already solved your problem.

     

    If not,

    What you have seems pretty good to me, it is looking for your metadata files in the BIN directory. i.e. BmsModel.csdl etc should all be in the BIN directory, are they?

     

    Cheers

    Alex

     

    Saturday, March 8, 2008 5:28 AM

All replies

  • Without a little more information about what you are trying to do it is very hard to help

     

    Can you share your ConnectionString (sanitized as necessary) and the code you use to get to this point please?

     

    Cheers

    Alex

     

    Friday, February 29, 2008 5:21 PM
  • No problem, here is the client code:

     

     

    private void Window_Loaded(object sender, RoutedEventArgs e)

    {

        try

        {

            using (var ctx = new BmsEntities())    <-- Exception occurs here

            {

                ....

            }

        }

        catch (Exception ex)

        {

            MessageBox.Show(ex.ToString());

        }

    }

     

     

    Here is the app.config:

     

    <?xml version="1.0" encoding="utf-8"?>

    <configuration>

    <connectionStrings>

    <add name="BmsEntities" connectionString="metadata=.\BmsModel.csdl|.\BmsModel.ssdl|.\BmsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

    </connectionStrings>

    </configuration>

     

     

    Friday, February 29, 2008 6:40 PM
  • Sorry for the delay in getting back to you Pierre, I hope you've already solved your problem.

     

    If not,

    What you have seems pretty good to me, it is looking for your metadata files in the BIN directory. i.e. BmsModel.csdl etc should all be in the BIN directory, are they?

     

    Cheers

    Alex

     

    Saturday, March 8, 2008 5:28 AM