I am having problem with my Entity framework connection string, this is the connection string i am using but I keep getting this error:
Connection string:
<add name="ElraProject1Container"
connectionString="metadata=res:///Models.ElraProject1.csdl|res:///Models.ElraProject1.ssdl|res://*/Models.ElraProject1.msl;
provider=System.Data.SqlClient; provider connection string='Server=dbXXX.appharbor.net;
Initial Catalog=Test;User ID=db0000; Password=PASSWORD;MultipleActiveResultSets=True'"
providerName="System.Data.EntityClient" />
Error message :
[ArgumentException: Keyword not supported: 'server'.]
I would like to point out that this connection works perfectly fine on localhost but not appharbor !
#1 Posted by friism Support staff on 19 Mar, 2011 01:25 AM
I think you're supposed to put
Data Source. Here's more documentation. Let us know if that doesn't resolve your issue.friism closed this discussion on 19 Mar, 2011 01:25 AM.
rahamohebbi re-opened this discussion on 19 Mar, 2011 06:15 PM
#2 Posted by rahamohebbi on 19 Mar, 2011 06:15 PM
I tried both Data Source and Server and none of them fixed it. Is there anybody who uses Entity Framework in appharbor ?
Thank you
#3 Posted by friism Support staff on 19 Mar, 2011 07:38 PM
I've gotten it to work with a connectionstring like this:
There's more Entity Frameowrk connection string discussion here.
#4 Posted by rahamohebbi on 21 Mar, 2011 02:52 PM
I have tried your connection string with no luck ! This is very strange !
#5 Posted by friism Support staff on 21 Mar, 2011 06:04 PM
Are you sure Entity Framework reads the connectionstring from the config file (and that it's not embedded somehow)? Which error did you get when using a connectionstring formatted like the one above?
#6 Posted by rahamohebbi on 21 Mar, 2011 06:08 PM
Yes sure it does, When I try this on my localhost everything works perfectly well. I even connect to the database on appharbor from my localhost and that works too.
#7 Posted by friism Support staff on 21 Mar, 2011 06:39 PM
Which app is this, I'll take a closer look? Also, you can invite [email blocked] as a collaborator, and I'll take a look.
#8 Posted by rahamohebbi on 21 Mar, 2011 11:07 PM
Dear Michael, I have added you to my collaborator list, I appreciate your help.
#9 Posted by friism Support staff on 22 Mar, 2011 12:56 AM
Couldn't this error stem from the fact that you host the ASP.NET membership parts in a different database and that the connectionstring associated with that is broken? Also, your site seems to work fine for content that is not in the
Adminarea.#10 Posted by rahamohebbi on 22 Mar, 2011 03:49 PM
I removed the membership connection ref from my config files and I still get the same error. Also as you have probably already found out I only use database in the Admin area for now. So all the other pages use dummy models that is why they work fine :)
#11 Posted by friism Support staff on 22 Mar, 2011 08:00 PM
The
ElraProject1Containerconnectionstring is defined in bothweb.configandconnectionstrings.config, could that be it?#12 Posted by rahamohebbi on 22 Mar, 2011 11:13 PM
I removed the duplicated one and I still get the error message. I am very much out of ideas now. This is very strange because it works perfectly fine on my machine...
#13 Posted by friism Support staff on 23 Mar, 2011 06:15 AM
I just tried pushing your code (no modifications) to a different site where it works: http://dealtest.apphb.com/Admin/BusinessType
I know its highly unsatisfactory to not find the root cause, but could I get you to try and create a new app and deploy it there?
#14 Posted by rahamohebbi on 23 Mar, 2011 10:13 PM
Thanks Michael, I created a new project and everything works fine now. But It would be good if we can find what is causing it because before this project (my third project) I created a second project that worked fine at the beginning and then the same thing happened to it.
#15 Posted by rahamohebbi on 23 Mar, 2011 10:19 PM
Ok right after I posted my previous post I managed to break the third one as well, this time I have some more clues. as soon as I created a new database in my third project and changed my connection reference to the new database (instead of using the connection string that connect the third project to original database) it failed again.
Would this be any help to you to find the problem ?
#16 Posted by friism Support staff on 23 Mar, 2011 11:09 PM
This could be because EF tends to drop databases, can you check if this workaround solves it? http://devtalk.dk/2011/02/16/Workaround+EF+Code+First+On+AppHabour....
#17 Posted by rahamohebbi on 24 Mar, 2011 07:20 AM
I am not doing it through code first, I created a edmx file for my model and I don't think this will drop anything.
#18 Posted by friism Support staff on 24 Mar, 2011 08:20 PM
I think your entity framework code somehow manages to write to the web.config. The version of your code we currently deploy to web servers uses
Data Source, but if I inspect the web.config on the actual web servers, this has been revertedserver-- presumably by some Entity Framework initialization. I think you should try to completely remove and re-add the Entity Framework stuff you use and to make sure that connection information is always read (and not written) ot web.config.#19 Posted by JjCoder on 01 Apr, 2011 01:40 AM
Well I will contribute to the troubleshooting on this one as it now just has me frikin pissed off... LOL
My edmx file outputs to an assembly an I am getting the error also.
Are you guys using a DbSet by chance? I think DbSets look for code first by defaul and we are using model first.
#20 Posted by Jjcoder on 01 Apr, 2011 01:47 AM
Interesting enough
public DatabaseContext():base("name=yourconnstringName")
This fixes the metadata keyword funky ass error!
You are tell ing DbContext to go into Model First mode not code first
#21 Posted by friism Support staff on 01 Apr, 2011 02:31 AM
Good find!
friism closed this discussion on 01 Apr, 2011 02:31 AM.
James Arceri re-opened this discussion on 01 Apr, 2011 11:22 AM
#22 Posted by James Arceri on 01 Apr, 2011 11:22 AM
I am assuming this fixed your exception?
-----Original Message-----
From: Michael Friis [mailto:[email blocked]]
Sent: Thursday, March 31, 2011 9:32 PM
To: [email blocked]
Subject: Re: Getting this error : Keyword not supported: 'server'. [Support]
#23 Posted by friism Support staff on 01 Apr, 2011 03:29 PM
@James did it solve your issue?
#24 Posted by James Arceri on 01 Apr, 2011 04:26 PM
Yes,
I was working with a repository originally posted at http://dotnetspeak.com/index.php/2011/03/repository-pattern-with-en...
Which is a great post on how to create a Generic repository. I ran into the issue with the MetaData keyword problem so I decided to modify the repository to
1.) Fix the issue with the EDMX file and connection string by creating a class that derives from DbContext
2.) There was an issue with the GetDBSet method in the original post with GenericTypes so I removed that method and added
DbSet<TItem> _set = _dbContext.Set<TItem>();to the CRUD methods.3.) Tested everything and WOW it works pretty well..
Here is the code
Usage:
If you can use this, greatness, if not oh well. I had fun burning a few hours reading the call stack lol..
#25 Posted by friism Support staff on 01 Apr, 2011 04:32 PM
Great, thanks for sharing!
friism closed this discussion on 01 Apr, 2011 04:32 PM.
rahamohebbi re-opened this discussion on 02 Apr, 2011 10:33 AM
#26 Posted by rahamohebbi on 02 Apr, 2011 10:33 AM
Thanks, I no longer get the same error, however I am now getting this error:
504 Gateway Time-out
This error comes up after about 1 minute.
#27 Posted by james.arceri on 02 Apr, 2011 11:58 AM
Can you send me your stack trace?
-----Original Message-----
From: rahamohebbi [mailto:[email blocked]]
Sent: Saturday, April 02, 2011 5:34 AM
To: [email blocked]
Subject: Re: Getting this error : Keyword not supported: 'server'. [Support]
#28 Posted by james.arceri on 02 Apr, 2011 11:59 AM
Are you using WCF by chance :) ?
-----Original Message-----
From: rahamohebbi [mailto:[email blocked]]
Sent: Saturday, April 02, 2011 5:34 AM
To: [email blocked]
Subject: Re: Getting this error : Keyword not supported: 'server'. [Support]
#29 Posted by james.arceri on 02 Apr, 2011 05:15 PM
Check your endpoints and make sure the server name is not in there.
-----Original Message-----
From: Michael Friis [mailto:[email blocked]]
Sent: Saturday, April 02, 2011 11:13 AM
To: [email blocked]
Subject: Re: Getting this error : Keyword not supported: 'server'. [Support]
#30 Posted by rahamohebbi on 02 Apr, 2011 05:24 PM
No I am not using WCF ! I only use edmx (model first).
There is no stack trace that I can give you, when I click on links that take me to pages that I use Database I get the 504 error message, all the other pages work fine.