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!
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.
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.'
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.
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.
My solution to this same problem (VS2013
) was this:
- Go to Model Browser
- Right click YourModel.edmx
- Update Model from Database
- Then it prompted me to select the connection. I selected the connection I wanted and proceeded to the next screen.
- Add/Refresh/Delete what you need.
- Select Finish and voila, the connection is here.
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").
精彩评论