Hi Everybody,
I have a large project in which i separate the developing and runtime databases from each other. I solved this by creating Linq model to the developing database and when programming, I set the Connection string as follows:
#if DEBUG
ConnectionString = GetConnectionString("DeveloperConnectionString");
#else
ConnectionString = GetConnectionString("ReleaseConnectionString");
#endif
Of course, both ConnectionString is included in my app.config file.
By this, the connection string is set whether I interprete my projects in Debug mode, or in something else.
At time of interpretation, Connection string gets its proper value.
But the program always gets the value from the developing database, and never from the runtime database.
Finally, I got to the point why it is so: The connection determines only the fact, by which database I sign in to the SQL server, but if I modify or query another database from there, that is valid, and most likely it is determined in the model this way.
How could I change things so that I couldn't make separate models for runtime and for developing versions?
Best regards,
Imre
Two database in one model
Re: Two database in one model
Probably, the DataContext constructors (that are generated in the *.Designer.cs file) use the name of the initial connection string. For example, the code should be like this:
We are sending you two sample projects with the necessary DDL/DML scripts to the e-mail address you have provided in your forum profile. Please check that the letter is not blocked by your mail filter. Please test it. If this doesn't help, please modify it so that the issue could be reproduced and send it back to us, or send us your sample project.
Code: Select all
public partial class TestMDataContext : Devart.Data.Linq.DataContext
{
...
#if DEBUG
static string ConnectionString = "DeveloperConnectionString";
#else
static string ConnectionString = "ReleaseConnectionString";
#endif
public TestMDataContext() :
base(GetConnectionString(ConnectionString), mappingSource)
{
OnCreated();
}
public TestMDataContext(MappingSource mappingSource) :
base(GetConnectionString(ConnectionString), mappingSource)
{
OnCreated();
}
...}