Archived Support Site

This support site is archived. You can view the old support discussions but you cannot post new discussions.

Getting this error : Keyword not supported: 'server'.

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. I think you're supposed to put Data Source. Here's more documentation. Let us know if that doesn't resolve your issue.

  2. friism closed this discussion on 19 Mar, 2011 01:25 AM.

  3. rahamohebbi re-opened this discussion on 19 Mar, 2011 06:15 PM

  4. I tried both Data Source and Server and none of them fixed it. Is there anybody who uses Entity Framework in appharbor ?

    Thank you

  5. I've gotten it to work with a connectionstring like this:

    <connectionStrings>
        <add name="FolketsTingEntities"
                connectionString="metadata=res://*/DB.csdl|res://*/DB.ssdl|res://*/DB.msl;
                provider=System.Data.SqlClient; provider connection string='Data Source=db000.appharbor.net;
                Initial Catalog=dbXXX;User ID=dbXXX; Password=YOURPASSWORD;MultipleActiveResultSets=True'"
                providerName="System.Data.EntityClient" />
    </connectionStrings>
    

    There's more Entity Frameowrk connection string discussion here.

  6. I have tried your connection string with no luck ! This is very strange !

  7. 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?

  8. 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.

  9. 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.

  10. Dear Michael, I have added you to my collaborator list, I appreciate your help.

  11. 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 Admin area.

  12. 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 :)

  13. The ElraProject1Container connectionstring is defined in both web.config and connectionstrings.config, could that be it?

  14. 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...

  15. 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?

  16. 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.

  17. 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 ?

  18. 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....

  19. 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.

  20. 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 reverted server -- 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.

  21. 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.

  22. 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

  23. Good find!

  24. friism closed this discussion on 01 Apr, 2011 02:31 AM.

  25. James Arceri re-opened this discussion on 01 Apr, 2011 11:22 AM

  26. 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]

  27. @James did it solve your issue?

  28. 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

    public class DatabaseContext : DbContext
        {
            public string _connectionString { get; set; }
            public DatabaseContext()
                : base("name=dfwforsaleEntities")
            {
                _connectionString = this.Database.Connection.ConnectionString;
    
            }
        }
    
    public class RepositoryBase<TContext> : IDisposable, IRepositoryBase where TContext : DbContext, IObjectContextAdapter, new()
        {
            private DbContext _dbContext;
            public DbContext CurrentContext { get; set; }
    
            /// <summary>
            /// Create new instance of repository
            /// </summary>
            /// <param name="DbContext">For embeded edmx resource please define base("name=yourAppEntities") in a class derrived from DBContext</param>
            public RepositoryBase(DbContext _context)
            {
                _dbContext = new TContext();
                CurrentContext = _dbContext;
            }
            /// <summary>
            /// Select data from database
            /// </summary>
            /// <typeparam name="TItem">Type of data to select</typeparam>
            /// <returns></returns>
            public IQueryable<TItem> Select<TItem>()
               where TItem : class, new() 
            {
                DbSet<TItem> _set = _dbContext.Set<TItem>();
                return _set;
            }
            /// <summary>
            /// Insert new item into database
            /// </summary>
            /// <typeparam name="TItem">Type of item to insert</typeparam>
            /// <param name="item">Item to insert</param>
            /// <returns>Inserted item</returns>
            public TItem Insert<TItem>(TItem item)
                where TItem : class, new()
            {
                DbSet<TItem> _set = _dbContext.Set<TItem>();
                _set.Add(item);
                _dbContext.SaveChanges();
    
                return item;
            }
            /// <summary>
            /// Update an item
            /// </summary>
            /// <typeparam name="TItem">Type of item to update</typeparam>
            /// <param name="item">Item to update</param>
            /// <returns>Updated item</returns>
            public TItem Update<TItem>(TItem item)
                where TItem : class, new()
            {
                DbSet<TItem> _set = _dbContext.Set<TItem>();
                _set.Attach(item);
                _dbContext.Entry(item).State = System.Data.EntityState.Modified;
                _dbContext.SaveChanges();
                return item;
            }
            /// <summary>
            /// Delete an item
            /// </summary>
            /// <typeparam name="TItem">Type of item to delete</typeparam>
            /// <param name="item">Item to delete</param>
            public void Delete<TItem>(TItem item)
               where TItem : class, new()
            {
                DbSet<TItem> _set = _dbContext.Set<TItem>();
                var entry = _dbContext.Entry(item);
                if (entry != null)
                {
                    entry.State = System.Data.EntityState.Deleted;
                }
                else
                {
                    _set.Attach(item);
                }
                _dbContext.Entry(item).State = System.Data.EntityState.Deleted;
                _dbContext.SaveChanges();
            }
    
    
            /// <summary>
            /// Dipose repository
            /// </summary>
            public void Dispose()
            {
                if (_dbContext != null)
                {
                    _dbContext.Dispose();
                    _dbContext = null;
                }
            }
        }
    

    Usage:

    DatabaseContext _dbContext = new DatabaseContext();
    RepositoryBase<DatabaseContext> _repo = new RepositoryBase<DatabaseContext>(_dbContext);
    var Categories = _repo.Select<Categories>().Include("Postings_Categories"); // Ooh it works with nav props nice!!
    

    If you can use this, greatness, if not oh well. I had fun burning a few hours reading the call stack lol..

  29. Great, thanks for sharing!

  30. friism closed this discussion on 01 Apr, 2011 04:32 PM.

  31. rahamohebbi re-opened this discussion on 02 Apr, 2011 10:33 AM

  32. 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.

  33. 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]

  34. 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]

  35. 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]

  36. 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.

Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac