locked
ADO Entity Problem: "Invalid object name 'dbo.Industries'" RRS feed

  • Question

  • After I create an Association between two tables in my database, using the ADO Entity Model & EDMX designer, I get the error "Invalid object name 'dbo.Industries'" when trying to create a new "Industry" and save it to my table.

    1. In my database I create tables "Industry" and "Proposal". 
       > Industry's field's are "IndustryId" (PK) and "Name"
       > Proposal's fields are "ProposalId" (PK), "IndustryId", "Title". 

    2. I (successfuly) add an "Industry" to the table with the following code:
       > ApplicationDBEntities db = new ApplicationDBEntities();
         db.AddToIndustries(new Industry { Name = "Technology" });
         db.SaveChanges();

    3. I then use the EDMX designer to create a one to many Association between "Industry" and "Proposal".

    4. One the Association is created I "Update Database From Model" and recompile.

    5. I then try to add a new Industry with the same code as above and I get the following error at db.SaveChanges();
    >"Invalid object name 'dbo.Industries'"

    I am guessing that some generated code is trying to use "Industries" and some other code is using "dbo.Industries", however I am not familiar enough with the Entity framework to know what I do to resolve this. Does anyone know the missing step?

    Friday, December 31, 2010 5:57 PM

Answers

  • Hi rdlecler,

     i think there is not any option like "Update Datebase From Model" in EDMX designer. the right option is "Generate Database from Model" . Once you select "Generate Database from Model" it will generate a sql script . Copy generated script and paste in your sql query window and run. or create association directly in database and select "Update Model from Database" from EDMX designer and save changes. try this, i think it will work.


    Thanks, Mukesh | [Remember to click mark as answered when you get a correct reply to your question]
    • Proposed as answer by Alan_chen Tuesday, January 11, 2011 4:27 AM
    • Marked as answer by Alan_chen Friday, January 14, 2011 1:08 AM
    Tuesday, January 4, 2011 5:50 AM

All replies

  • On 12/31/2010 12:57 PM, rdlecler wrote:
    > After I create an Association between two tables in my database, using
    > the ADO Entity Model & EDMX designer, I get the error "Invalid object
    > name 'dbo.Industries'" when trying to create a new "Industry" and save
    > it to my table.
    >
    > 1. In my database I create tables "Industry" and "Proposal".
    > > Industry's field's are "IndustryId" (PK) and "Name"
    > > Proposal's fields are "ProposalId" (PK), "IndustryId", "Title".
    >
    > 2. I (successfuly) add an "Industry" to the table with the following code:
    > > ApplicationDBEntities db = new ApplicationDBEntities();
    > db.AddToIndustries(new Industry { Name = "Technology" });
    > db.SaveChanges();
    >
    > 3. I then use the EDMX designer to create a one to many Association
    > between "Industry" and "Proposal".
    >
    > 4. One the Association is created I "Update Database From Model" and
    > recompile.
    >
    > 5. I then try to add a new Industry with the same code as above and I
    > get the following error at db.SaveChanges();
    > >"Invalid object name 'dbo.Industries'"
    >
    > I am guessing that some generated code is trying to use "Industries" and
    > some other code is using "dbo.Industries", however I am not familiar
    > enough with the Entity framework to know what I do to resolve this. Does
    > anyone know the missing step?
    >
     
    Go look at the desiner.cs for the entity and see the generated code.
     
    Sunday, January 2, 2011 1:01 AM
  • Hi rdlecler,

     i think there is not any option like "Update Datebase From Model" in EDMX designer. the right option is "Generate Database from Model" . Once you select "Generate Database from Model" it will generate a sql script . Copy generated script and paste in your sql query window and run. or create association directly in database and select "Update Model from Database" from EDMX designer and save changes. try this, i think it will work.


    Thanks, Mukesh | [Remember to click mark as answered when you get a correct reply to your question]
    • Proposed as answer by Alan_chen Tuesday, January 11, 2011 4:27 AM
    • Marked as answer by Alan_chen Friday, January 14, 2011 1:08 AM
    Tuesday, January 4, 2011 5:50 AM
  • Hi rdlecler,

     I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, January 11, 2011 4:28 AM