Does original DB change when the linked DB changes? - c#

I have two different projects sharing same SQLite database(One is Web-api, Other one is WPF App). However, the database is located in (let's say project A). In the project B, I used "Add as link" to copy the DB to project B.
I have three questions
If the DB in project A changes, the linked DB also changes. However, if i change the DB in project B, does the original DB change?
Is there any better way to do this?
Will it still work if i release the solution.
original DB
copied DB
properties of copied DB

A local database like a sqllite file should be installed to appdata.
This is user specific by default, but there's also a public user you could use.
It's up to your installer - and that means you - to put it there.
If this file is to be shared by two apps.
You would need to configure whatever you're using as an installer to write to a common location in appdata. That should be under public if multiple users need to share the file.
By default, if you add a file as content and copy if newer that will end up in your bin when you develop and it will work for you. When you install, if you install to program files the sdf will end up in there as well and your user will not be able to write to it.
There's a more complete explanation of appdata files here:
https://social.technet.microsoft.com/wiki/contents/articles/30915.c-local-files.aspx

Related

How to update the version of my app without deleting client database using advanced installer

I have an application on a client machine and I have to fix some bugs. When I'm trying to update using the advanced installer my app loses all of localdb data on the client (the update replaces the database file).
I want to know how to make my update version project replace all files except localdb files.
My files:
The is a Do not overwrite existing file option available in Files and Folders view for the related file. You can try to use it and this should work.

How to keep databases changes on access database on a portable executable created with Enigma Virtual Box

I am working on a desktop project with c# with Access database. Now I have finished my project and I need to have an executable file contains all the components and ddls and my access database of my project.
In other words, I want an executable file runs portable.
Fortunately I was able to create this portable executable file by Enigma Virtual Box and my project works fine on all windows without any installed.
But there is a problem that i could not solved it. when i inserted or updated or deleted any record in access database every thing is fine. but when i close my application and run again Everything is back to normal.
In other words, when I run the application previous database copied again in executable file.
In this case one can not help? Or there are other solutions for the portable executable file?
After any change of data base you must rebuild exe file, you can't save changes in exe file. So dont pack database.

Where do I put a folder that is used in my C# application?

I'm planning on my C# application having a folder called Data that is reused whenever the program is launched. I put it in the root of my Visual Studio solution which causes it to be where you see below
MyProject (File folder)
bin (File folder)
Debug (File folder)
MyProject (Application)
.
.
Data
obj
.
.
.
.
after the project is built ... but I'm guessing I'd want it where the actual application is, right? Or is it proper for me to instead have a "Create if doesn't exists" for that folder in my application? Sorry if this is considered a subjective question.
1) you may check it at the start of the program if it doesn't exist then you may create it.
Right click on your SOlution in visual studio>> Add new project>> Under other project types>> Choose>> Setup and deployment >> Visual Studio installer >> Set up project.
Setup projects are important in many cases, when you need to make any changes for first time installment or need to modify registry, need to copy some data folder or other settings for the first time.
2) Create a setup project and in your setup project you may create that data folder, which will be created when user will install the application.
I would prefer to use both option to avoid any issue in future.
From what it looks like in your example the data folder you created in your application/solution explorer. So far so good but it wont ever be created inside your project.
You have 2 options if you want it to be in the same directory as your application.
You create a .txt file or whatever you want to put into it later on in the solution explorer and say "copy always" in the properties
Is you create your folder manually inside your program. The base location of your program is usually AppDomain.CurrentDomain.BaseDirectory. Thus you could use Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + folderName).
For 2 this could be done on each run on the program (if the directory does not exist yet OR on setup of the program if you have a special setup routine).
As far as I'm aware all of these variants are legit and are dependent on your exact use case and personal taste.
I'm guessing I'd want it where the actual application is, right?
NO! Let's say you eventually bundle this program into an installer the puts it in it's own Program Files folder. Standard Users do not have write access to anything under the Program Files folder!. You just forced your program to require Administrator rights every time it runs.
Instead, you need to put your data folder in the Application Data special folder:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Deployment practices for .NET

I have a new application i would like to deploy to a Managed Server I have recently signed up for. I would like to know what would be the best way to deploy to it. In my experience I have seen that many of the asp.net applications just push dlls to the server. How is this achieved?.
I have Tortoise SVN as my subversioning system. I have a repository on another server and usually i commit my changes and then update my release folder in the managed server but this has all the .aspx, solution and other files I belive are not needed. How can I do my set up so that I only push the dlls and when updating that only dlls are updated?.
I am not too clear on this and would like an explanation and best practices given this scenario.
I have faced similar questions before and follow the below steps every time I move the compiled files for incremental fixes in my application.
Maintain two separate copies of the solution files - Local Application and Production application
//This is very important because once you go to production environment. One copy for your local working and other copy only for deploying in the live server. This copy should be up to date with your live server copy.
Make the changes to files and compile and test the application in your local application folder/solution. Now commit only the files that you edited. SVN will take care of this. It will show you a possible "red mark" for the files which differ from the updates present in the repository. In this way you can track the pages which were modified.
Now open open your production solution folder and update the folder. This will update the files in production application folder.
Now compile and test the changes done. Verify if its issue is fixed or the changes are reflected same as the Local application copy. Now build the application and publish to a folder.
To know the modified files:
DLLs:
Go to the bin location of the folder and "order by" modified date. These are the dlls which are to be copied and replaced with in your life server.
ASPX/ASCX
a) Open SVN of production application folder. Right click and click show log. This will show all the files modified/updated with date. Select the ones last updated and note down the location.
b) Now navigate to the location in your published folder and select those files "ordered by" descending/ascending modified date of the files. Replace those files alone to your LIVE server.
Note: This is certainly not the best possible solution, but one of the general practices followed throughout the industry. There are few other plugins which can track changes and publish the relevant files to your published folder. But again ,this is applicable only if you have the source codes and application files in the same machine as of the one you are hosting the application from. Let me know if you have any question in this.
You can just use visual studio web deploy, it will automagically figure out what needs to be updated and only pushes what is necessary unless you ask it otherwise.

How to change the solution structure in TFS?

How to restructure a solution that is currently being maintained by source control? I need to create a couple of folders and move the existing projects to folder and another folder to maintain dependencies etc..
so, shall I make the changes in source control itself? or from my local machine? I am facing it difficult to make changes locally (where I mapped the project to source control) and sync (check-in) the changes as the structure itself is completely get modified.
So I am thinking the changes has to be made at source control? Pl suggest me.
It is easier to do this in TFS for a few reasons:
You will create a historical change set of what was moved or renamed, vs. doing locally you will be forced to do adds/deletes
TFS will automatically move the folders on your machine and update the mapped paths.
If you also need to rename anything (which you didnt mention, but it can be considered part of code organization), TFS also updates solution files appropriately when you rename projects, so you don't have to remove and re-add projects to your solution that includes renamed projects.
The only note is that often you will have files and folders such as bin and obj folders that are not in TFS, and those will not get moved by TFS, leaving half empty directories. You will need to clean those up manually on your machine.

Categories