I am creating an Asp.Net MVC 3 multi-user web application and first use the EF4.1 code for the db model.
For development, I use SqlServerCE in App_Data with pleasure, and for production this will move to Sql Server 2008.
Say my context is called "MyModels", by default it first searches for the connection string code "MyModels" in Web.config. It can be said to use the file in App_Data or change to access the database in SQL2008. So far so good.
But because of the multiple leases, I would like the SqlServerCE file name to correspond to the unique identifier of the tenant (therefore, App_Data would have "client_x.sdf", "client_y.sdf", Sql Server 2008 would have separate databases), I can’t Understand how to direct these different databases.
I tried MyModels, which inherits from DbContext, and provided a connection string (using the string "placeholder" conn in Web.config and replacing "{clientId}" with a unique identifier), and I also tried to establish a string connection in the MyModels constructor:
base.Database.Connection.ConnectionString = xxx;
but this does not seem to work. I always get the following error:
, , SQL . . , SQL . (: , : 40 - SQL Server)
( , "" SqlServerCE, Sql Server. !)
, Database.Connection.ConnectionString Web.config , , , , "placeholder" conn .
, , "". - ?