Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create database on remote server using Entity Framework 5.0

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.

like image 306
user1815835 Avatar asked Mar 23 '26 21:03

user1815835


1 Answers

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;

like image 150
Alex Avatar answered Mar 26 '26 11:03

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!