add two new columns and delete a column

Govind Sankar

Active member
Joined
May 15, 2020
Messages
42
Programming Experience
Beginner
Hi

I am a beginner level C# programmer. But currently I have a task to work with a Database created in C# using Visual Studio. My knowledge on database is also very limited.My first task is update the current existing database. i.e add two new columns and delete a column. My question is where should I begin. Should I just work on C# program. Do I have to make any changes with the Database Management System. This is my current doubt. If it is just C# I can learn on how to do it. If there are other things to be also done, I done know what other things I have to learn. Kindly do help me. Thank You.
 
Hi, welcome to the forums.

A good place to start would be a search engine rather than a forum. We will mostly only help when we have seen you to be making an attempt and then we offer guidance based on what you've already tried. But since you haven't tried, there is nothing to help you with. We are not going to do the research for you, as that is what you need to do, and once you study how it's done, and understand the requirements, then you can come back to the forums and show us your attempt at writing the required code, and explain any issues you are having with said code. First search bing for c# add two new columns to sql database
 
This really depends on your database.

Let's talk about relational database engines first:

Traditionally, updating the database schema for database that uses a SQL based database engine is done outside of the client programming language. So you would normally run a SQL script that adds or deletes columns.

Microsoft, mimicking a few no-SQL databases, has also implemented a "code first" approach to using their Entity Framework. In "code first", you just modify your C# entities, and Entity Framework will take care of sending the necessary SQL commands to modify the database schema to match the changes in the entities the next time the code is run. Older versions of Entity Framework only supported a "database first" approach where like above the database is created and modified outside of the C# code.

Now for no-SQL databases:

Most object oriented databases let you just modify your code by adding and removing fields and the system just works. On the other hand, most object oriented databases don't really expose any tables or columns. From the programmer's point of view, you only ever see objects.

For most document base, and key-value based databases, you would also just start using the new "fields" that you want to use and they will magically be stored without requiring any explicit schema changes. For anything that you don't want to use anymore, you can just stop using them, but if you want to conserve space, you may need to run an explicit command clean out the database.
 
Back
Top Bottom