Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert rows in to SQL Server using Visual Studio's Server Explorer

I have created a Database in MS SQL and loaded the Database in my Server Explorer. In my MVC application, I wish to simply populate a single entity inside my database (Customer Name for example), does anyone know how I can send data to the database I have loaded? I can't seem to figure it out.

Any help will be highly appreciated.

like image 551
Subby Avatar asked Jun 27 '26 10:06

Subby


2 Answers

If you're asking about how to insert data in Visual Studio itself, open Server Explorer, add a Data Connection to your database, expand the Tables node, right click on your table and select Show Table Data. This opens up a screen where you can add data.

like image 107
David Atkinson Avatar answered Jun 29 '26 07:06

David Atkinson


If you only want to connect and populate one entity you should consider using Code First Entity Framework to drive your model using a plain C# class on the entity.

Scott Guthrie has a post on how to do that: Using EF Code First with an Existing Database, and Ralph Lavelle has a post that's more specific to MVC and includes migrations in the second part: Using Entity Framework Code First with an Existing Database (1/2) and Using Entity Framework Code First with an Existing Database (2/2).

like image 23
Turnkey Avatar answered Jun 29 '26 05:06

Turnkey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!