Shared Non-Sitefinity Database Issue

Posted by Community Admin on 04-Aug-2018 15:28

Shared Non-Sitefinity Database Issue

All Replies

Posted by Community Admin on 29-Feb-2012 00:00

I've been having lots of trouble getting a custom module installed the way I want to get it done.  So I broke everything down to the simplest components and I was able to get it installed in this fashion.  However, one of my requirements is that the data in the custom module be stored in a database separate from the Sitefinity Instance database.  I thought this would be really easy to do so what I did was add a new entry to the data.config of my project.

I've changed the actual names but this should give the idea.

 

<add connectionString="data source=SERVER1;Integrated Security=SSPI;initial catalog=SitefinityInstance" providerName="System.Data.SqlClient" dbType="MsSql" name="Sitefinity" />
  
<add connectionString="data source=SERVER1;Integrated Security=SSPI;initial catalog=SharedDatabase" providerName="System.Data.SqlClient" dbType="MsSql" name="SharedDatabase" />

I then changed the name name in my CustomControlContext.cs to use the "SharedDatabase" string.

public static CustomModuleContext Get()
        
            return OpenAccessConnection.GetContext(new CustomModuleMetaDataProvider(), "SharedDatabase") as CustomModuleContext;
        

When I register the module, it doesn't show up in the content section with other modules and if I check the database where it should create the tables, it creates "sf_dynamic_type_base" but not the table that would contain my module information.

Can I use a separate database like this?  If so, what am I missing?

Posted by Community Admin on 29-Feb-2012 00:00

In a couple of my projects I had to add a separate database for my own stuff (non-Sitefinity). It worked fine. Just like you, I have added the second connection string, referenced to it in code and used it with no issues at all.
Now, that I am thinking about it, I probably could have just added the extra table(s) to the Sitefinity database and eliminated the need for two databases. I was a bit unsure about whether the Sitefinity's upgrade procedure would affect my tables in any way. Perhaps someone from Telerik can answer: If I add my own table to the Sitefinity database;
1 - Do you recommend it?
2 - Do you ignore non recognised tables in your upgrade procedure?

If the answer is Yes and Yes, then next time when I need to store some stuff, I will just create a table in the Sitefinity database.

Posted by Community Admin on 01-Mar-2012 00:00

Thanks for the response.  I eventually got my module to start working but now I noticed that when it created the database on the backend it created the columns in a very unfriendly matter.  For instance, my table is saving contact information but the Sitefinity ORM order the columns so that the ZIP code is first when I would like to have the key first. Is there anyway to order this through code or do I need to fix it manually in the DB?

This thread is closed