Setting up Orchard development workspace - asp.net

I'm just learning orchard CMS, and have some questions:
How do I setup development environment for the team? should I use source code of orchard itself (I don't want that) or is there a way to use Orchard in compiled state?
I would prefer each developer to have its own local copy of DB, won't it make troubles for the team when they get sources and need to go in admin mode and manually execute updates on modules?

For development you should definitely set up full source enlistment. Using the compiled, deployment package (as can be downloaded from Codeplex or via WebMatrix) will drive you in lots of problems.
Orchard can run on either "normal" SQL Server or SQL Server Compact (single-file) databases.
What do you mean by a "local copy of the DB"? Each developer can test his instance using local SQL Server CE database - it's how I usually do that when working on custom modules.
If you have some preconfigured database you'd want your developers to use (because eg. it contains some sample data, themes setup and such) - each developer can copy the database from the server to his own, local SQL Server CE-based database. Migration can be easily done from Visual Studio, SSMS or WebMatrix.

Related

How can I implement a local testing database for my Azure Website?

I have a website I'm developing that uses an SQL Azure database. I want to be able to test my website using a database locally hosted on the debugging machine so that my designer can work on style and content without having to deal with the overhead of firing up the Azure emulator and communicating with an external service as he is often in areas with no-connectivity.
I imagine it would be possible to extract the .sql scripts to create the database and execute them every test run, but this seems tedious. Similarly I'm not sure what the best way to configure these deployment details would be in order to switch between development, and published configurations. I'm a new web-developer cutting my teeth on a rather large project.
Using ASP.NET MVC4 and have MSSQL 2012 installed for what it's worth.
You can export your SQL azure database as .bacpac format and then import it into your sql server database. It will create all tables and fill with data. You don't need to do it on every test run, just do it once and you will have proper database for debug needs.
Switching between debug and release (or you can rename it if you want, e.g. Local and Production) configurations and using different web.config (or config transformations) is a good way to work with different settings.
If you want to store your db scripts (db structure or data) in your VCS - you can use Entity Framework migrations (new fancy way) or separate project of "SQL Server database" type (old school but proven way :) ).
Also EF migrations allows you to easily recreate db (with different name) on each run (for unit testing purposes. And then you can use SQL Express file instance (keep in mind that it's only for local work, your designer wont be able to access sql express instances afaik)

ALM - Application Lifecycle Management - Build and deployment challenge

I am stuck with a problem that I could use some feedback on to solve it in the best possible way.
The issue revolves around source control -> automated builds -> deployment. Basically ALM (Application Lifecycle Management).
We have a product – an ASP.NET Web application with a MS SQL database. This product is running on hundreds of websites with associated databases across multiple virtual machines in our production environment. At the moment the web applications and database are running on servers with IIS 7 and SQL Database Server 2008 R2. The product itself is source controlled in Team Foundation 2012.
For years the release of new versions of the product has been once or twice a year for years. Now we are going to focus on releasing more frequently and hence we need a strategy for the ALM for the product.
The deployment strategy now:
In the development period between the releases, the SQL update scripts has been created manually – each time a database change was made a script was updated. When the application is ready to be deployed it gets compiled on a developer machine. The database with all the changes used would be backed up into a .BAK file. The web application, the .BAK file and the update SQL script would be packaged (.zip) and uploaded to the production environment ready for deployment.
Update existing running products:
Copy/paste the web application in the target website physical folder.
Update the web.config file – connectionstring and application
variables. Run the update script via SQL Management Studio
This would be done for each and every customer – hundreds of times.
This is a very tedious and error prone task and I don’t like it at all!
What I would like to do instead is;
Source control the database as a Database Project in Team Foundation
Automatically build the web application with Team Foundation 2012
Build Server.
Deploy the output from the Build Server to the multiple websites of
the production environment along with automatically generated SQL
update scripts run against the SQL Server.
I have been googling my ass off - only finding bits and pieces regarding builds, deployment, automatic SQL update script etc.
What I think is partly the right direction is to source control the database and use the TFS Build Server. I am very confused on how to do the deployment itself in an easy and controlled way using the output from the TFS Build server.
Ideally I would want to the TFS Build server to create a package with the latest version of the Web application, the latest version of the database, post deployment script including an auto generated SQL Update script from the previous build to the current build. This could be contained in e.g. a nuget package. Then I would want to be able to create an additional web application which should manage the deployment – target, version, iis website, sql server, web.config connectionstrings etc.
Does anyone have any advice on how to achieve this? How do you do this?
You can use a release management tool to do this, no need to create an additional web application.
One such example is Deployment Manager, from Red Gate. (Disclaimer: I work there.) It has built-in deployment actions for ASP.NET apps and SQL Server databases. The command line tool RgPublish.exe can be used to create a package for the web app as you describe from TFS Build. The same can be done for the database using the sqlCI.exe command line and associated NANT/MSBuild scripts.
The same packages can then be deployed to each of your servers. You may run into scalability issues with 100s of websites though.
The database deployment works by generating the upgrade script automatically, though you can change the behaviour to put the upgrade script in the package, when the package is first built. These are called "dynamic" and "static" upgrade methods respectively.

How to automatically check out a database file in a source controlled web application?

I am working on an ASP.NET web application, we are a small team (4 students) and we do not have access to a dedicated server to host the database instance. So for this web application we decided just to put the database file in the App_Data folder.
The problem is that our project is source controled on TFS, so every time you open the solution and try to launch the web application, we get an expcetion saying that database is read-only. That is logical because the databse file is not automatically checked-out.
Is there a workaround to avoid a manual check-out of the database file everytime we open the solution ?
Thanks.
Never check in MDF files. You should develop your project with a deployment script that creates the tables and other database objects you need. Never modify the MDF directly from VS Server Explorer. Use a version based approach to database schema.
I know you'll say 'but is hard', but trust me, the alternative which VS wizards guide you is far worse. Not only from a team development point of view, but from deployment point of view too. After you deploy v1 of you site, you'll make changes and want to deploy v1.1 or v2. Each time, you'll face the same dilemma: you have 4 MDF files, one on each team member enlistment, and 1 on the deployed site, and there is simply no way to align the schemas. You'll end up asking for SQL diff tools like SQL Compare, but they cost a tonne of moneys and they're far from perfect when it comes to maintaining a SQL schema.
Besides, having scripts as your database source will also align well with all the other source control goodies, like tracking down who changed what and when.
If you are able to install "Visual Studio Team System Database Edition" add-on for Visual Studio (previously called "Visual Studio Team Edition for Database Professionals", previously called "DBPro") you can import your current database into a Visual Studio Database project, which can be part of your overall VS Solution.
This then allows you to manage schema objects (tables, stored procs, permissions etc.) in Visual Studio and integrates your database schema nicely with TFS.
It also allows you to deploy the schema in your VS Project to the database server, automatically handling modifications without causing data loss (or failing if data would be lost).
The add-on for VS 2008 is located at:
http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&displaylang=en

SQL server express backend for ASP.NET web service

I come from a linux/apache/php/mysql background. For my current project, I am forced to write web services using ASP.NET. I have installed visual studio and created an ASP.NET web service project. The web service I'm creating will use a SQL database backend. I see that visual studio installed "SQL Server Express 2008." I can see that there is a service called "SQL Server (SQLEXPRESS)" that is running. My question is, how do I run queries against this database? Where's the front end? What tool do I use to create databases and tables? Is there something else I have to install?
I feel completely lost and my google-fu fails me. There are so many different SQL products from microsoft that I can't tell what is the easiest path to just having a simple database with tables I can query from my development machine. With MySQL, I would install the MySQL database, download MySQL query browser and start firing queries at it. How can I do that with Visual Studio/SQL Server Express?
You can download SQL Server Management Studio from here. This is the GUI for working with SQL Server. It will let you create databases, tables, stored procedures, etc. as well as writing queries and manually edit data in the tables.
Aside from SQL Server Management Studio, you can use the Server Explorer tab in Visual Studio (by default on the right side, next to Solution Explorer) to add a data connection. You can do most of the most common database tasks (create/query tables, create views, etc) from there.
there's a command line tool that installs with SQL Server (all versions) called SQLCMD.exe, should be in your install path.
Visual Studio also lets you create dbs, run queries, look at table structures and data (including creating and deleting them, etc), you do that by opening your Server explorer window and making a connection to your local instance (.\SQLExpress by default).
Finally, as the other person mentioned, SQL Server Management Studio Express is a free download, and well worth the time it takes to install.

Best practices for maintaining shared hosting websites with ASP.NET and SQL Server?

I've been doing PHP/MySQL websites with shared hosting providers for the last couple years. The day-to-day process is basically:
develop in Eclipse, one website per folder
upload via FileZilla, one website per folder
use PHPMyAdmin to create and manage your local and online databases and transfer data from one to another
to backup the online database I do dump of the database tables into script and copy them locally
I now want to build websites with ASP.NET with SQL Server 2008 on shared hosting providers, and am trying to get into this new paradigm, hopefully some of you can give me some pointers based on your experience and tell me what I am not doing optimally:
I've installed both the Visual Web Developer 2008 Express as well as the full version of Visual Studio 2008, both seem to be full-featured tools for developing ASP.NET sites. In terms of websites at shared hosting providers, what can you do with the full version that you can't do with the express version?
I use FileZilla to upload my sites, which seems to work fine. Do you use an external FTP program to upload your sites or do you use the "Publish" or "FTP Website" in the above IDEs?
I installed SQL Server 2008 Management Studio and can now issue SQL commands to my online SQL Server database (although I strangely can't see my database in the list on the left, I can still access it, I assume this is some rights issue with my provider, www.domainbox.de, but this provider told me to use their online manager instead, which is called "ASP.NET Enterprise Manager" which is extremely simple but at least has a "Query Box" which allows me to send queries to my database.) Is this "ASP.NET Enterprise Manager" standard with ASP.NET hosters or is there something else that is better, e.g. where you could edit your data in the grid, etc.? And I assume that with most providers you are able to manage your online SQL Server database with SQL Server Management Studio, is that correct? (I remember back in 2001 managing online SQL Server 2000 database at a shared hosting provider with Enterprise Manager and it would take literally 10 minutes for me to see my database on the left because it listed out the other 800 customer databases as well -- hopefully this has been solved by now).
How do you backup your data in your online database to local storage? (currently I would have to write code that output my data to some other format, e.g. XML or SQL Script)
And after you make a number of structural and data changes to your local database, how do you transfer those changes and the new data to your online database? (I had to install SSMS Tools [http://www.ssmstoolspack.com] to be able to dump my data into a script so that I could get it back into my online database).
So, although I've gotten most things to work, I feel like there must be better ways to go about this, better providers, better tools, etc. Would like to hear some "best practices" advice from anyone who works with ASP.NET, SQL Server and shared hosting.
For the most part, what you're doing now will work with an asp.net website.
For your development environment, I don't think you will be limited by using Visual Web Developer 2008 express for what you want to do. Here is a microsoft page that compares every version of visual studio 2008, including Visual Web Developer 2008 Express: Visual Studio 2008 Product Comparison
For deploying your website over the net, I would generall stick to deploying manually. You can use some of the automated stuff in visual studio, but your deployment will tend to be a little slower. After compiling your application, it will then delete every file in your destination website, and upload everying from scratch (uncompressed I think). Your whole site will be down while this happens. When you deploy manually you can upload just the changed files, or everything in a compressed format.
Regarding the SQL server, many shared hosting services will let you connect with some sort of local SQL management tool. However, connecting this way generally uses a lot of bandwidth so they throttle the allowed bandwidth for this way down. This is probably the performance issues you previously saw. If you can get by with it, I would use their hosted SQL tools for most of your work, but then use the management studio for anything it can't handle.
For backing up your SQL server, if your host doesn't have a way for you to perform an automatic backup then you will have to do something yourself. I would first check to see if they will allow you to at least run a SQL backup command. This will generate a .bak file of your database, but on the local database server. Most places will work with you on this, since many customers need this.
For applying changes to your database, your best bet is to script all of the changes into one sql script and run it using the remote SQL management tool. These aren't hard to write, and there are a few tools out there that will help you with it. I personally like to use Visio. It lets me compare two databases (local and remote) then generate a script to apply to the remote one with all the changes.
Good luck
As far as capabilities of VS Express vs Standard - Standard is still the better tool. It gives you a richer debugging experience, broader support for solutions/projects dependencies among other things.
These things still matter even when doing shared hosting b/c you absolutely need to debug your app (client and server side). You can do this adequately with Express with some caveats (cant attach to an arbitrary process, client side javascript debugging is a pain), Standard makes this MUCH easier.
For publishing/deploying - I would recommend 'Web Depoyment Projects' - an MSBuild extension that you can download from MS. This gives you a lot of customizability of how you want to build and deploy your website - which can include sending it to an FTP site. If you have ever used MSBuild and like it - Web Deployment Projects are the easiest hook to extend your build process with an ASP.NET website.

Resources