Using multiple connection strings.

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/22/2011 3:20:20 PM
Gravatar
Total Posts 22

Using multiple connection strings.

Hi,

Im currently building a custom module which I am attempting to use Entity framework for my data and business layers. I added the tables to the mojo default database and then created the datamodel in my data layer. I then added the connetion string for my datamodel to user.cofig. My 2 connections strings in user.config are where Booking_connectionstring is my ado.net connection string:

<add key="MSSQLConnectionString" value="server=SQLEXPRESS;UID=user;PWD=Password;database=mojobooking" />
 <add key="Booking_ConnectionString" value="metadata=res://*/BookingModel.csdl|res://*/BookingModel.ssdl|res://*/BookingModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=SQLEXPRESS;Initial Catalog=mojobooking;User ID=user;Password=Password;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

However now when i run setup or launch default.aspx I  get the error: 'Booking_ConnectionString' is an unexpected token. Expecting white space. Line 12, position 41.

In this article http://www.mojoportal.com/using-a-different-database-for-a-feature.aspx joe states "In order for it to work, the alternate connection string must be specified in Web.config or ideally user.config before you run the setup page"

Dose this mean that I should have added the second connection string before I ran setup initially?? If anyone has any experience adding a 2nd connection string after the initial setup could they please let me know how they did it.

Cheers

Keith

 

3/23/2011 1:55:19 PM
Gravatar
Total Posts 22

Re: Using multiple connection strings.

After a lot of head scratching the problem was resolved by adding the connection string to web.config instaed of user.config. user.config would not accept the connection string format generated by entity framework. I eventually saw the obvious solution and added directly to web.config

3/24/2011 11:00:46 AM
Gravatar
Total Posts 9

Re: Using multiple connection strings.

I use it in user.config as
<appSettings>
....
<add key="mojosvnEntities" value=" .... " />
....
</appSettings>

and i use it like ;
mojosvnEntities mjE = new mojosvnEntities(ConfigurationManager.AppSettings["mojosvnEntities"].ToString());
mjE. ...

i hope it helps
 

You must sign in to post in the forums. This thread is closed to new posts.