none
EF always creates database on the local SQLExpress RRS feed

  • Question

  • Hello 

    No matter how I specify a connection string to Entiry framework, il always creates the database on the local sqlExpress

    I have and asp.net MVC with the Model as a separate  project (dll), I have the same  connection string to a remote server in "app.config" and also in the DbContext constructor, when I run the applciation, the database is created locally 

    Monday, December 10, 2012 2:31 PM

Answers

  • the problem occured because I had a deafault constructor (with no arguments) in my context, EF migrations uses it and creates a local database . I deleted the default constructor and  every thing worked as expected :) 
    • Marked as answer by shiboob Tuesday, December 11, 2012 3:17 PM
    Tuesday, December 11, 2012 3:17 PM

All replies

  • Hi,

    what is the output of : ctx.Database.Connection.ConnectionString

    where ctx is the DbContext object ?


    One good question is equivalent to ten best answers.

    Monday, December 10, 2012 2:37 PM
  • it returns the remote server connection string, when I run "add-migration" and "update-database" on the PM, it updates the local database. I should have pointed that the remote database was not created  with EF migrations enbaled .
    • Edited by shiboob Monday, December 10, 2012 3:14 PM
    Monday, December 10, 2012 3:12 PM
  • the problem occured because I had a deafault constructor (with no arguments) in my context, EF migrations uses it and creates a local database . I deleted the default constructor and  every thing worked as expected :) 
    • Marked as answer by shiboob Tuesday, December 11, 2012 3:17 PM
    Tuesday, December 11, 2012 3:17 PM