Datawarehousing with ASP.NET MVC - asp.net-mvc

On one server there are more than 20 databases with identical structure but different data. I need to collect some of the data (the same queries) from all databases and store in new database which is located on another server. I decided to use ASP.NET MVC 2 but it doesn't seem logical to use more than 20 "LINQ to SQL Classes" (.dbml) files because the structure is the same for all databases and it's repeating if I use so many of these files. Is there a simple way to use one .dbml file (for remote databases) but change only connection string?

I agree that you really wouldn't want to use MVC as that is a web framework and has nothing to do with moving data around.
You can also look into using an ETL tool to accomplish this task. I have used RhinoETL in the past successfully to accomplish something similar.
There are also multiple posts on this site discussing ETL tools. For example, check the following link - https://stackoverflow.com/questions/51198/what-etl-tool-do-you-use

According to this, you can pass in a connection string with the dataContext constructor. So theoretically, you should be able to have one dbml file, but you can instantiate multiple instances of your data context, each with a different database connection string specified. Each context should then point to their respective database and allow you to work with multiple databases.

Why do you want to use ASP.NET MVC at all? ASP.NET is for web UI, not data warehousing (except when you need to display cubes). Looks like you use SQL Server. If that is true you can utilize Integration Services (ex DTS) to do the job.

Related

Using a file-based data structure instead of a database in ASP.NET

Is there a way to use a file-based data structure in ASP.NET that can be easily switched with the EntityFramework or other ORMs later?
(I want to use the typical MVC structure and not change much later)
I want to delay the decision which database to use for as long as possible while developing.
It's possible to do this with the repository structure.
The repository implementation reads the data from the files and creates the model instances.
Those can be passed to the views normally like EF-Models then.

Using MVC with multiple different databases

I have used MVC thus far in a traditional EF sense by creating POCO first objects and then adding this to a database context but I have a new problem in that I am trying to recreate a legacy system but using the MVC framework but it uses a connection to multiple different databases and tables.
In the legacy solution they use Enterprise library to create the link to databases but I am not sure that this is the best option available and was wondering what are the options open for dbconext in regards to different database connections at the same time, is this possible?
The question is nothing to do with MVC. Besides, ASP.Net MVC (Presentation Layer) should not even need to know about what kind of ORM or database at Data Access Layer.
Back to original question, it is not worth using Entity Framework, if you have to query two databases at the same time.
I suggest you want to look at other ORM like Dapper.

architecture of Umbraco application

I m new to Umbraco, I have watched Umbraco.tv videos and want to use Umbraco in a project as a cms for managing and editing content. I am highly thankful for your guidance, time and for your thoughts on 3 questions:
How a Umbraco based data driven proejct should be architecutured ? For custom database tables do you use a separate database or same Umbraco database ?
How you work with custom data (non content) ? Do you make everything a document type, even if it is data which you are not going to create content of, for example a simple form submitted data ?
For DAL what technology or ORM you use ? Does Umbraco provide any API for saving simple data which is not a content or document type ?
Thank you so much once again.
1 The architecture question is important but it also has be considered against how complex the project needs to be.
I would usually recommend a separate database for non-Umbraco data since this keeps everything nicely independent and manageable especially as projects grow. It also means that CMS-specific data (i.e. content) can be kept separately from none-CMS data, e.g. user registrations.
However, if the project is small and isn't likely to grow, keep it simple. Use the same database and piggy back off Umbraco's implementation of the Petapoco ORM. For example:
ApplicationContext.DatabaseContext.Database.Save(new Thing());
Or
var item = ApplicationContext.DatabaseContext.Database.Single(thingId);
2 For custom data, again it's a matter of need, maintainability and simplicity. Only use document types for what needs to be and can be stored in the CMS. My personal rule is that if it isn't content or organises content then it doesn't belong in the CMS. For example news and news categories obviously belong in the CMS. However, the comments made on an article have no reason to in the CMS.
3 With regards to DAL, as I have said, Umbraco has an implementation of Petapoco that can be used out of the box. If the project is basic enough, just use that. There is little point in using anything else unless you need some separation and/or some additional grunt in which case I would recommend using NHibernate or EF.
In addition to the points above,
Use NuGet;
Use the MVC mode of Umbraco, as it will provide you with substantially more flexibility. Check out the Hybrid Framework as it provides a very good start point for a robust and flexible project architecture;
http://www.youtube.com/watch?v=0PtzyrEFG7I.
You always need a doctype in Umbraco, even if a page doesn't offer any WYSIWYG type editability
I would recommend using a Service Oriented Architecture, and the .dlls you drop into Umbraco can call the service. You can then deploy this service and have full control over how you do data access. Choose whatever method you want. Most modern sites use an ORM and it doesn't matter which, although nHIbernate and Entity Framework are the favourites. Don't be frightened to mix and match a more direct form of data access though as it can give you more control, especially in situations where performance optimisation of large queries is important.
If you're not familiar with adding custom .NET functionality into Umbraco, Trying out adding .NET user controls into Umbraco will give you a good start, and to help you to understand how you can utilise your own .dlls in Umbraco:
http://umbraco.com/help-and-support/video-tutorials/introduction-to-umbraco/developer-introduction/using-net-user-controls.aspx
Anything custom I put in the same database as my Umbraco installation, but everything in custom tables. I don't touch the Umbraco tabes, I would not want to affect my future version updates.
Form submitted data I store in my own custom tables, I avoid creating content nodes with those, it's often tricky and doesn't give me the flexebility I often need. What I do instead is create an "Admin" document type, that is behind login (hard coded access, but easy to hook up to Umbraco users / members if wanted) and use my own custom UI to display my stored custom data.
I use PetaPoto (http://www.toptensoftware.com/petapoco/), it's a micro ORM that is added through a single file (installation is so easy then), using the same db connection string. Then I create custom models as I need and with with parts of the MVC. I normally stay away from route hijacking and rather use Surface Controllers and ajax calls for almost everything.
Hope this helps!
You can use the database containing the Umbraco tables for tables not used in Umbraco. If there are no hosting problems for you using multiple databases then you can simply link to a second database in the web.config - this would be safer than using the default Umbraco database as Umbraco packages often add database tables & there could be naming conflicts.
Viewing non-Umbraco data (eg from a database) is best done by adding macros that access the data using standard .Net patterns (eg razor scripts, .Net User Controls) & then in Umbraco you add in a reference to the macro in the template (view). You can use multiple templates (views) for any document type; so if you have a document type called 'forms' that contains no data you can use the 'allowed templates' checkboxes to say which view(s) are valid for this document type. When you add a content item you must specify a doc type at the start, but the template (view) can be changed at any time.
If you are storing data any .Net ORM will work with Umbraco (see http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software#.NET) I've used Linq to Sql, Subsonic & Dapper before now - but there are lots of options.
Take a look at my example using umbraco within Onion Architecture
https://github.com/afroukh/OnionCMS

ASP.net MVC, I want one database, not multiple

I am following the guide on the asp.net site for learning asp.net mvc4.
Link : www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/
Thing is, I want to put my movies table in the Default connection. Because I want all of the data to be in ONE database and not two.
I mean. I am confused as to why I can't just have one database, with separate tables. Surely multiple databases will introduce latency, and also scalability issues to my project.
How can I get around this?
That Default connection points to your local db and is what is used for the forms authentication stuff. That db has all of the asp.net role provider schema stuff in it and since it's an "internet" project this is where all the login stuff goes. if you want to have your entities and models hook into that same database when you add your entity framework model point it at that db and your good to go.
After a little further investigation:
It looks like http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-a-model is where you define your connection string for your entities. I noticed AttachDbFilename=|DataDirectory|\Movies.mdf in there, and after verifying my thoughts http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/f21c0728-935d-492a-baaf-ff2704e3683b/ it looks like that is what is spinning up a second database in the app's data directory called movies.mdf. If you want to keep your 1 default database, change the connection string information in your MovieDBContext string to that of the default connection and and it should create your new movie structure within that same database.

ASP.Net MVC: Where to store Application and Admin Panel settings? Web.config?

Having built myself a decent website using ASP.NET MVC, I'm about to build an "Admin Panel" for users in the "Admin" Role to control the website with. Specifically, the website that I've built is an internal site for an enterprise and it consists of a bunch of mini web-apps, each of which need to be configured and/or tweaked from time to time.
Is Web.Config the appropriate file to store these application settings?
Should it be in a separate XML file?
A DB Table (or set of tables)?
Currently, I have no DB available to me, but perhaps at a later date I will. Currently, I'm inclined to create an XML file and store values there. Is this a reasonable approach? Or am I missing something obvious on how to do this?
EDIT: Ok, here's my abstraction layer (Interface):
public interface IAppSettings
{
IQueryable<string> GetValues(string component, string setting);
void SetValues(string component, string setting, List<string> values, bool append);
}
I figure I can read/write to Web.Config, another XML, or a DB this way.
What do you think?
I would recommend you a db. Writing to files in a multi-user/multi-threaded application could be challenging and problems could arise if you don't synchronize the access to those files, not to mention transactional access if you ever needed such. There are some lightweight NoSQL databases which could be extremely useful and easy to setup.
Whatever you choose make sure to create abstractions over the data access layer so that you could easily switch later to another method like a SQL database if you will (after trying a NoSQL database you probably won't will :-)).
The question to ask here is, in general, is this a set of settings that will change with the codebase or be changed by users? If it is the former, XML is the way to go -- it can easily be version controlled with the code. If users are changing it then a database is a better option.

Resources