3

I've got an existing EF4.1 project which is working just fine. I've added a new SP to the DB which returns a new kind of an entity (an existing entity with some additional fields).

The problem is when I try to import the function to the EF - it won't create my complex type. the wizard writes that "no database connection has been configured for this model". Which is strange - because it does see the new SP and everything.

I've tried creating my own, new complex type, but it won't map the fields as needed (some type conversion issues)

Any ideas what could be done?

Thanks!

2
  • Are you sure your SP always returns the same resultset? Commented Aug 15, 2011 at 14:06
  • Sure! It's a plain SELECT query Commented Aug 15, 2011 at 14:22

6 Answers 6

5

To build on Malako's answer, I have a simlar situation. My problem was that my connection strings are in an external file

<connectionStrings configSource="some_other_file.config">

The "Update Models" wizard has a bug where it will not look in the external file for connection strings, and I cannot leave a connection string in the connectionStrings tag since it must be empty or it will give an error when building.

The workaround for me is to use the Update Wizard, check the box that says "Save entity connection string in Web.config", and then add all my function imports. When I'm done, I comment out the connectionString so my project will build. Next time, uncomment that entity connection string before updating models.

Annoying, but at least there's a way to get it to work.

Sign up to request clarification or add additional context in comments.

3 Comments

Yes that's how I do it but what happen next time that you add a new store procedure, then you have to add the connection string again other wise it will be no map when you try to get the columns yo get a message on the "Edit Function import" you will See a message saying "No database connection has been configured for this model". so my work around is to re install the estore procedure again but what happens when I have 20 or more then every time I will have to re do all store proc.. or create a new model?? @Rocketmonkeys
here is the link of my solution there is a video and everyting but Im trying to figure How to do it with out deleting the model or adding the connection string VIDEO LINK
@Xvegas - It'd be great if you were to post the solution here, either as a comment or another answer. Links to outside sources often go bad for one reason or another, and way down the line no one will know what your solution was. Thanks!
1

For me, how I got it to work in my model project. There was other connection strings I left in there that had "server=" in there (non-EDMX related). I just deleted those other connection strings and the EDMX update wizard works as advertised.

Error message seen: Unable to update the App.Config file because of the following exception: 'The 'server' keyword is not supported.'

Comments

0

I assume the ConnectionString property of the entity model is empty. Check in model browser.

The easiest way to fix this is to remove all the connection strings in the .config files. Do a search for

connectionstring="

Delete the line(s) entirely or comment it/them with

Delete your edmx and recreate it. Make sure 'Save entity connection settings in Web.config as:' is checked.

Now the ConnectionString should be set and you will be able to generate complex models via function import.

Comments

0

if it still not works for you then remove other connection strings. and re add new. the same problem is solved by this. removing all the connections string and added the Entity framework's connection string first then added the others but changed the name.

Comments

0

My solution to this same problem (VS2013) was this:

  1. Go to Model Browser
  2. Right click YourModel.edmx
  3. Update Model from Database
  4. Then it prompted me to select the connection. I selected the connection I wanted and proceeded to the next screen.
  5. Add/Refresh/Delete what you need.
  6. Select Finish and voila, the connection is here.

Comments

0

You have to add the connection string again every-time you add a stored procedure. Otherwise it will be no map when you try to get the columns you get a message on the "Edit Function import" you will See a message saying "No database connection has been configured for this model".

So my workaround is to re install the stored procedure again but what happens when I have 20 or more then every time I will have to re do all stored procedures. Or create a new model, this is the cons of this.

Here is the link of my solution there is a video and everything but I'm trying to figure How to do it with out deleting the model or adding the connection string VIDEO LINK OR stack overflow solution since there is not way yet to map store procedure I use a class my company has to retrieve has table from the store procedure and then send the data as JSON String if you want that solution let me know and then I will tray to do the code with the explanation (its done with a .dsn conection string and ODBC "Open Database Connectivity").

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.