3

I am using Entity Framework 5.0 code first to create my database. This framework works fine and creates a database on my local instance of mysql. However, if I try and point at a sql server on my remote server then I have found many difficulties. I have changed the connection string and also used this code below in the DBContext constructor (DBRisk) so that I am pointing at my remote database.

 public RiskDB()
 {
     this.Database.Connection.ConnectionString = 
         "Data Source=Data Source=217.111.222.194;Initial Catalogue=RiskDB;User ID=xxx;Password=yyy";
 }

I have followed the advice on stackoverflow and had no resolution

This is the error - it seems to indicate it is targeting a sql ce database. I don’t know how to address this and migrate to the correct remote database as the connection string is configured correctly. The permission on the database are ok for database creation

Error

Checking if the context targets an existing database...

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Keyword not supported: 'initial catalogue'. at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) Exception has been thrown by the target of an invocation.

This error happens when the connection string is configured for SQL Server and the migrator provider is configured for SQLCE.

1 Answer 1

1

Try to replace "Data Source=Data Source=217.111.222.194; with "Data Source=217.111.222.194;

According to http://www.connectionstrings.com/sql-server-2012, connection string may be:

For Standard Security:
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

For Trusted Connection from a CE device:
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI; User ID=myDomain\myUsername;Password=myPassword;

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

8 Comments

Thank you for your reply. The Data Source point you made was just a cut and paste error on my part into this post so the connection string is correct. I still get the 'initial catalogue' error. Any further suggestions?
Have you tried Initial Catalog instead of Initial Catalogue?
Create new connection from Visual Studio, press Test Connection, and copy generated ConnectionString to be sure that it's not the root cause of the problem.
Hi, I have managed to get through 1.enable-migrations 2. add migration 3. add-database in package manager thanks to an update of the connection string (using the advice above). However, the database has not turned up on my server even though a migration file has been created! This is the connection string but can you offer any further verification and tracing advice?
This is the string ( see above )Password=xxx;Persist Security Info=True;User ID=yyy;Data Source=217.111.222.194
|

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.