shared project and database - c#

I have a visual studio project and I want to use it on another computer. I found that there is a way to upload the project but I wanted to know if its possible to share also my database so it will be linked to the project anytime I change the computer Im working with, and the database will update itself on both computers.
?

create a database project along with your c# project and put all your tables, stored procs, etc. in it. check in the database project in your version control. when moving to a new computer "publish" the database project the first time, or do a "sql compare" any consecutive time to apply the db changes.
https://msdn.microsoft.com/en-us/library/hh272677(v=vs.103).aspx
https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx

Related

How can I make Visual Studio use my database instead of the .mdf file located in App_Data folder in ASP.NET MVC project?

I am creating an ASP.net Web Application (.NET Framework) in Visual Studio 2019 and I select the ASP.NET MVC template and I use individual user accounts option. On the other hand I have a SQL Server database created by myself (let's call it DemoDb).
After Visual Studio creates the template, under App_Data folder in the solution explorer, it creates the .mdf database file which also includes the AspNetUsers, AspNetUserRoles etc. tables.
What I want to do is, transfer all the authentication tables to my DemoDb database and let Visual Studio use those tables.
I did a lot of research in internet including StackOverFlow. I edited web.config files connection string entry to point to my database but it did not work.
Is there anybody WHO will guide me step by step to achieve my goal? Thanks a lot.
First Step is Copy (transfer) Identity Tables to your Main Database, then Find "IdentityDbContext" in your project. it should be in "Models\IdentityModel.cs".
then find this code:
public ApplicationDbContext() : base("DefaultConnection")
and change "DefaultConnection" to your Connection String.
it's better you do this job, before First Compile.

Renaming file in setup project in visual studio

I have written a WPF/C# desktop application with a standard setup project. When the application is installed, an sqlite database is placed locally on the users file system. Now, I have renamed my app and I want to rename the database as well. I have renamed the database file in the solution explorer (the corresponding file in project folder is automatically renamed) and on the File System tab of the setup project. However, the name of the database under the setup project in the solution explorer is not changed.
I am not sure whether this really matters, Source path and TargetName for the setup project database has the new name and everything seems to work. But i figure it could be confusing for someone else with dirrerent names for the same database, and I worry it could lead to some problem I cant foresee.
Does anyone know how to solve this?
Maybe you can edit it directly from the project file, if i remember correctly its an xml

VS 2012 Install Shield Installer SQL Compact

Good evening!
Here is the thing, i've been trying to create a setup project for my app which includes some winforms and a SQL Compact Data Base.
I already added to my VS 2012 the required installation to create install shield installers for my apps, i add it to my project and i follow the instructions.
Once im asked to add the required files to their destination computer paths i add on the install directory the interface final results and to a C:\ folder, the data base final results. I of course changed the database connection to that new folder.
I proceed to generate the installation and then use it on my own computer, everything goes smooth, and once it finishes, i launch the app, it works okay, but upon opening a form which has a datagridview inside of it (or i click a button that has a connection with the database) i get an error messagge telling me that the db files could not be found.
I go to the database folder and it is there, but it doesnt work, the thing is, if i go to my VS 2012 projects folder, open the DataBase project folder and i copy the database inside of it (.sdf file) and i paste it in the new folder for the program, the app works just fine.
Any suggestions? what am i doing wrong?

How to get SQLite database file working as embedded resource with C# published project

I've searched extensively and I followed loads of advice (pretty much all saying the same thing) with regards to this problem, but it still won't work.
I'm building a C# graphing application using Zedgraph, and using an SQLite database. I was still tweaking the DB until recently but now it's correct and I want to add it as a resource to my project, so that when I publish my Project, it's be part of the setup and will work with my application. I've added the resource the way one usually does it, and it's in my resources folder in the project. I have it set to Copy Always and it's as an embedded resource. I'm not sure if this is correct though. My application builds and runs fine from VS. But when I publish, it can't find my tables as the DB file is obviously missing.
How can I get the DB file working with the application so that I can distribute my app?
Thanks.
Are you using a Visual Studio Installer Project? If yes, it might be that the file is not being included in the installer file. You can force-add it from the Dependencies in that project.
Check this one out for adding external files.

how to make c# project with database independent of visual studio

I made a Backup and restore project on visual studio , along with another project. They both use the default database of visual studio. They both have to bundled together along with the database, so it runs without Visual studio. I have tried to use the default VS installer, but i don't think that allows me to use the database aswell.
I have decided to use NSIS to make the installer. What all files, libraries etc. do i need to make the database and project function together, independently(without visual studio). How can i do this ?
Thanks
What kind of database do you mean? MS SQL or MySQL or another?
E.g. to create MySQL database from NSIS you can simply run command line utility and pass your sql script as parameter so the utility will create everything what is in the sql file.
Other database types simply need to extract their database file somewhere to disk and set appropriate paths.
Your question is very vague, there is more details needed to answer you.

Categories

Resources