none
I created an EF model, and now I've got these problems RRS feed

  • Question

  • I created a database/model in VB 2010 (NOTE THE VERSION!) using Entity Framework, Model-First, and I have the following problems:

    1. I get 3 "messages" regarding my App.config file, saying,

      >>> Could not find schema information for the element "supportedRuntime"

       >>>Could not find schema information for the attribute "version"

       >>>Could not find schema information for the attribute "sku"

      What does this mean, and how do I fix it?

    2. I want to programatically create one or more new instances of the database, using the pre-defined model and schema, from scratch. (cf. my earlier post, "How do I create a new database file at run-time with a predefined schema in Entity Framework?") When asking about this, I was advised to use the System.Data.Entity.Infrastructure namespace and IObjectContextAdapter interface. NEITHER THE NAMESPACE OR THE INTERFACE APPEAR TO EXIST, and I worry that they below to a more recent version of VS than I'm using. If I can't use this namespace and interface, is there a work-around?


    Robert Gustafson




    Sunday, September 8, 2013 8:25 AM

Answers

  • I would say it's just a hiccup. You should delete the model out the project, go down to the folder for the project and delete the edmx, delete the app.config and shutdown VS2010. Restart VS2010, rebuild the model and verify the model.
    • Marked as answer by RobertGustafson Wednesday, September 11, 2013 2:48 AM
    Sunday, September 8, 2013 9:22 PM
  • Hi Robert;

    To your statement, " I was advised to use the System.Data.Entity.Infrastructure namespace and IObjectContextAdapter interface. NEITHER THE NAMESPACE OR THE INTERFACE APPEAR TO EXIST, and I worry that they below to a more recent version of VS than I'm using.", you are partly correct the IObjectContextAdapter was introduced in version 4.1 of Entity Framework and is used by DbContext which is the default data context used by EF since version 4.1. But seeming that you are already using the ObjectContext which is the default data context for version 4.0 and below you should still be able to do what your previous post had suggested by changing this line of code :

    ObjectContext objectContext = ((IObjectContextAdapter)db).ObjectContext;
    
    // to this:
    
    ObjectContext objectContext = new YourObjectContextClassName();

    Where YourObjectContextClassName is replaced by the actual object context class in your code.

    Now if you are already using an ObjectContext you do not need to create a nother one just use the one you have.

    The only other thing I see that will need changing is in this line of code from the link you referenced:

    objectContext = new ObjectContext("metadata=res://*/S09.csdl|res://*/S09.ssdl|res://*/S09.msl;provider=System.Data.SqlClient;provider connection string=\"data source=(localdb)\\v11.0;initial catalog=" + DBName + ";integrated security=True;MultipleActiveResultSets=True;App=EntityFramework\"");
    

    The value S09 will need to change to the name of the EDMX filename without EDMX. For example if the name of the EDMX file was Model1.edmx then the above line becomes :

    objectContext = new ObjectContext("metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=\"data source=(localdb)\\v11.0;initial catalog=" + DBName + ";integrated security=True;MultipleActiveResultSets=True;App=EntityFramework\""); 
    

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, September 9, 2013 2:49 AM

All replies

  • Hi Robert;

    I am not sure if I can be of help in this question but lets start off with what version of the .Net Framework are you using?

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Sunday, September 8, 2013 3:00 PM
  • I would say it's just a hiccup. You should delete the model out the project, go down to the folder for the project and delete the edmx, delete the app.config and shutdown VS2010. Restart VS2010, rebuild the model and verify the model.
    • Marked as answer by RobertGustafson Wednesday, September 11, 2013 2:48 AM
    Sunday, September 8, 2013 9:22 PM
  • I'm using NET 4.0.

    Robert Gustafson


    Sunday, September 8, 2013 11:35 PM
  • Hi Robert;

    To your statement, " I was advised to use the System.Data.Entity.Infrastructure namespace and IObjectContextAdapter interface. NEITHER THE NAMESPACE OR THE INTERFACE APPEAR TO EXIST, and I worry that they below to a more recent version of VS than I'm using.", you are partly correct the IObjectContextAdapter was introduced in version 4.1 of Entity Framework and is used by DbContext which is the default data context used by EF since version 4.1. But seeming that you are already using the ObjectContext which is the default data context for version 4.0 and below you should still be able to do what your previous post had suggested by changing this line of code :

    ObjectContext objectContext = ((IObjectContextAdapter)db).ObjectContext;
    
    // to this:
    
    ObjectContext objectContext = new YourObjectContextClassName();

    Where YourObjectContextClassName is replaced by the actual object context class in your code.

    Now if you are already using an ObjectContext you do not need to create a nother one just use the one you have.

    The only other thing I see that will need changing is in this line of code from the link you referenced:

    objectContext = new ObjectContext("metadata=res://*/S09.csdl|res://*/S09.ssdl|res://*/S09.msl;provider=System.Data.SqlClient;provider connection string=\"data source=(localdb)\\v11.0;initial catalog=" + DBName + ";integrated security=True;MultipleActiveResultSets=True;App=EntityFramework\"");
    

    The value S09 will need to change to the name of the EDMX filename without EDMX. For example if the name of the EDMX file was Model1.edmx then the above line becomes :

    objectContext = new ObjectContext("metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=\"data source=(localdb)\\v11.0;initial catalog=" + DBName + ";integrated security=True;MultipleActiveResultSets=True;App=EntityFramework\""); 
    

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, September 9, 2013 2:49 AM