in Education by
If you're anxious to get to the point of this, just skip to the last paragraph. I'm totally new to MVC2 and I've been tasked with creating a database management application with it. After spending a few weeks getting the hang of it, I've finally begun writing my production code. In order to test my code out, I need to be able to access the copy of the database on a dev server. When it's time to put a release version up, it obviously needs to work with the live database. Initially, I created two side-by-side models (using the entity framework) of the maintenance database and just changed the namespace of the other one to something like DevModels and opposed to just Models in order to avoid name clashes (they're the exact same model, just different sources). This caused more problems than it solved. Anyway, while pouring through the book Pro ASP.NET MVC 2 Framework, I got the bright idea to just change the datasource in the Web.Config file. This way, when I publish the app, it will automatically have the correct datasource. Long story short, this didn't exactly work and caused more problems than it solved. Anyway, I've done some looking around but I just can't find anything. All the material I find is rather unspecific and leaves me more confused. I'm sure there's a simple way to do this as it HAS to be a common thing. So, in summary, how do I write an MVC2 application once and be able to use the model with different datasources so I don't have to heavily modify code to make a production version of my application? UPDATE: Here's the connection string before and after I change it. Before=dev server `metadata=res:///Models.MaintModel.csdl|res:///Models.MaintModel.ssdl|res://*/Models.MaintModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source=EXP_POWERSUITE2;Initial Catalog="Maint DatabaseSQL";Integrated Security=True;MultipleActiveResultSets=True'" `metadata=res:///Models.MaintModel.csdl|res:///Models.MaintModel.ssdl|res://*/Models.MaintModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source=EXP_POWERSUITE;Initial Catalog="Maint DatabaseSQL";Integrated Security=True;MultipleActiveResultSets=True'" Also, in order to make sure I had the right connection string, I started a new app and made a new edm with the same names and everything but geared towards to live database. I was looking for any obvious differences but it was the exact same thing as what I have above. Also, I can retrieve and display rows from the database in my application. I just can't add them. I'm using MS SQL Server Manager 2008 R2. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can get the desired results by changing the connection string in the web.config to point to the new datasource. This will only work if the new database you are pointing to has all the tables, columns, references, etc as your development database. If it does not match, then your model will not match the new database and you will get errors. If you decided to make a change to your development database, then you must make sure that change is in the new database you are pointing to or otherwise the model will not match.

Related questions

0 votes
    If you're anxious to get to the point of this, just skip to the last paragraph. I'm totally new ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    @ConditionalOnClass({ DataSource.class, EmbeddedDatabaseType.class }) This configuration is only enabled when _______ A. Class in ... or above is used D. Any of the options...
asked Nov 8, 2022 in Education by JackTerrance
0 votes
    In order to create the proper queries I need to be able to run a query against the same datasource ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    Which annoatation is used to inject an datasource into an ejb?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    Which is true about DataSource API? 1. Build in support to read data from various input formats like Hive, Avro, JSON, ... , etc. 4. The top layer in the Spark SQL architecture....
asked Oct 22, 2020 in Technology by JackTerrance
0 votes
    I have a dataset, say: DateJoined Name Number DateLeft 11/03/2015 Tom 001199 11/03/2019 11/03/ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    name any four tools in Gimp used for changing the pixel arrangement in an image Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    _______________ is used for changing color and font formats, inserting clip art or switching other formatting within the document. Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    The device used for changing the direction of the engines is called?...
asked Jan 6, 2021 in Education by JackTerrance
0 votes
    Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    Deadlock is a situation when thread is waiting for other thread to release acquired object. (a) True (b) ... Multithreading of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Suggestions needed for creating better and efficient search indexes for models having foreign key and many-to-many ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    I'm getting started with CQRS, and thought It would make the most sense to use the Command object ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
...