I currently have an ASP.NET MVC 3 project, plus a class library project, that I am planning on open-sourcing. Before I do that though I want to clean up the project a little bit. One modification I want to make is with the database. Currently the site is published to a shared hosting server and I setup the SQL database on that server. However, since people will be forking the project and running it locally I'd like to just attach a SQL server express database or something that is part of the project. I want people to clone the repository, open the project, press F5 and have it run. Currently they'd have to setup a SQL database and create all the tables and stuff.
The solution consists of two projects: MvcUI and Domain. Domain is where all the application logic occurs. In fact, the domain is UI agnostic which means that it could be consumed by a desktop application just as easily as it could be by a web application.
I would like the database to be part of the Domain (class library) project. I have never done this before. If anyone could provide a simple explanation for how I would need to go about setting this up I would be thrilled. It would be very nice to have the database just be a in the solution because I could pre-populate it with some basic data. What do I need to do to get this database in my project as a database file or what not?
SQL Server Compact Edition is a portable SQL database that should do exactly what you are asking.
Microsoft SQL Server Compact 4.0 is a free, embedded database that
software developers can use for building ASP.NET websites and Windows
desktop applications. SQL Server Compact 4.0 has a small footprint and
supports private deployment of its binaries within the application
folder, easy application development in Visual Studio and WebMatrix,
and seamless migration of schema and data to SQL Server.
Related
I have create a Windows application in WPF using Visual Studio 2013, and I'm using MySQL as database, now I want to include MySQL as a distributable package in my setup file.
I am new to development and have very little idea about deploying the software, and i have been searching over the internet but hardly finds any good article which explains the steps to perform the task.
A MySQL database is supposed to be setup on a (remote) database server that the client applications connect to. You don't (or at least you shouldn't) set up a server on each workstation where your client application is installed on.
What you probably want is a self-contained database that can be shipped with your application and run "as-is" without any remote servers or specific setup.
SQLite is a popular example of such a database.
Getting started with SQLite in C#: http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/
Use this:
https://marketplace.visualstudio.com/items?itemName=UnniRavindranathan-MSFT.MicrosoftVisualStudio2013InstallerProjects
And then follow this:
http://geekswithblogs.net/TarunArora/archive/2014/04/24/visual-studio-2013-installer-projects-ndash-hello-world-installer.aspx
There will be settings which you will be setting when creating installer with the wizard, one will be like pre-requisites for the program and will ask you for a MSI location for that program. Dump the location of your LocalDB or whatever MySQL software that you are using (Popular ones are SQLite/SQL Server Express). When the user starts to install the program it will make them install your SQL prerequisite software before moving onto installing your program.
I have a team working on a project. For the purpose of collaboration we are using Team Foundation Server.
Now we want to create a shared database so that each team member can connect to the database, manipulate it, and retrieve data.
I've already created a SQL Database Project and I've added it to TFS but I don't know how to connect to it from my code ?
The SQL Database Project is just a representation of the database schema and objects. It isn't a database that you "connect to".
Instead you will need a SQL server running somewhere. You might decide to run it locally on each of your dev machines or have a common server that everyone accesses. Either way, a regular SQL server needs to be installed somewhere.
This doesn't have anything to do with TFS. This is just a Visual Studio project like any other.
What exactly do you mean by "connect to it from my code"? .NET code doesn't directly interact with a database project, but can form a data access layer to interact with a database.
If you right-click on the database project in Visual Studio, there is an option to deploy (or perhaps publish, depending on the Visual Studio version). You can deploy the database project to a live database and then your .NET code can interact with that database.
This can be multiple databases. For example, your automated builds can deploy to a shared database for everyone to use, and individual developers can deploy to their local workstations for development and debugging purposes.
The Sql Database project is not a database in itself - it is a project that describes a database. You need to deploy that project (typically to an instance of Sql Server) in order to connect to it in the way you describe.
In a typical team development environment, each member of your team might have their own local instance of Sql Server, and deploy the project to it. In this way, your team members won't get in eachother's way as they create and delete data during the course of development. You will possibly also want a shared instance for a more formal testing environment.
So ultimately, what you've created is not a shared database: it's a template that a database can be created from.
Ive been working on a project on my computer and i want to transfer it to my laptop. The project is an ASP.Net Website Project in C#. I'm using SQL Server 2012 to hold my database and the Asp.net user management tables in my database also.
What's the easiest way to do this, as i have backed up my database and copied the ASP.net website folder onto my laptop and changed data source, but I'm getting a few errors, especially on the asp.net configuration page it has also removed my roles due to the transferring.
If i understood you correct, what you need is to deploy the ASP.NET Membership Database to the new project location. There are set of tools and commands that you need to use.
You would need to construct a command-line like the following:
C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -verb:sync
-source:dbfullsql=" [your connection string] "
-dest:dbfullsql="c:\temp\InsertIntoAspNetDB.sql
Again the exact path and command will depend on your local configuration.
You may get more detailed information from MSDN - How to: Deploy a Database With a Web Application Project
I just finished writing a large program that uses a pretty large database file. In the past, when I finished writing programs, I just uploaded the .exe file to my website and sent the link to whoever wanted to use it, but now there's also a database file to include..
Is there a way to "wrap" the database file in the .exe? If not, how can I release my program so that the user only has to download one file? I've never created an installer, nor do I really know how.. I've only ever just uploaded .exe files :).
Any help would be appreciated. Excuse my inexperience :P.
The program is programmed in C#, and the database file is in .mdf format (I am running SQL Server 2008). I'd be happy to provide any more details. :)
Instead of bundling the entire database, you should make the application know how to create the database. A simple way is to create a script for the entire database in SQL Server Management Studio. Then include the script (probably after you've made some adjustments to it) in the exe file as a resource file.
A better approach than rolling your own solution is to use a data access framework such as EF Code First with Migrations that has database creation and upgrade support built oin.
You can make simple setups from visual studio (Create new setup project). If you need more advanced features, have a look at Windows Xml installer
You can include the free Sql Server Express so your users don't have to buy a license of SQL server. If you want to go through the effort of building an .msi installer, I believe you can do SQL-server - specific actions.
On the other hand, if you have a small amount of data, you might consider using the filtering features of Dataset instead of relying on SQL server.
Edit: Microsoft has a new SqlServer 2012 LocalDB that might be interesting:
New to the SQL ServerĀ® Express family, LocalDB is a lightweight
version of Express that has the same programmability features, yet
runs in user mode and has a fast, zero-configuration installation and
short list of pre-requisites. Use this if you need a simple way to
create and work with databases from code. It can be bundled with
Visual Studio, other Database Development tools or embedded with an
application that needs local databases.
(excerpt from here)
I have one problem with service base database, I have used it in one of my application but I dont know if user who'll use it need to have something installed to be able to run application (like you need to have installed NET framework for c# applications)
Note: This is windows application
It depends on what database engine you're using. SQL Server/SQL Express/Oracle/MySQL require you install the application on the machine before it'll work. databases engines like SQLite and Firebird are just Dll's, so you can include then in your project.
If the file is an MDF that's a SQL Server file - you need to install SQL server, or SQL express.
You can include it with your app and do it silently:
http://social.msdn.microsoft.com/forums/en-US/sqlsetupandupgrade/thread/7180e4dc-5c1e-4501-83d7-6882abb1f04e/
You will need to install the relevant database engine with the correct service name, and create the database and relevant objects on installation.