Create dynamic columns in SQL Server table connected to ASP.NET MVC - sql-server

I am new new ASP.NET MVC and databases. I want to create a table in SQL Server with some columns, but the number of columns depends on the data coming from a datafile on ASP.NET, any suggestions? Thanks for your answers in advance!
It's an ASP.NET MVC app, so I am trying to create dynamic model but it's not yet working...

Related

Can't see my Entity tables in Add New Data Sourceā€¦

HI i've trying to do simple application using Entity Framework and SQL server database. I am using that http://msdn.microsoft.com/en-us/data/jj574514.aspx tutorial. Everything is perfcet untill Bind Object to Controls part. I don't see my tables in that tree structure. Do u have any ideas why? All i want to do is show data from my SQL server table, using entity framework.

Displaying Data in a SQL view, need to save to a SQL table Code First Entity Framework 4.1

I am supplying data to my MVC 3 website from a SQL view. I'm using the view because I'm having to display data from a different database. How do I go about taking changes that the user makes to the view and save it to the core table?

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.
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.
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).

How to Add or Delete tables from database using Yii web application?

I am using Yii to create a web application that allows me to view, retrieve, add, and delete information from tables in a MySQL database I have already created.
Is there a way to implement this web app so that I can add or delete tables from the database using the webapp instead of having to login to phpmyadmin?
For example, My database might have 2 tables: "Employee" and "Department". How can I customize my Yii webapp so that I can add a third table "Location" on the fly, using the webapp?
Use the CDBCommand class. It has many database management methods, including dropTable and createTable
In Yii there are having CDbCommand class. With the help of this user can customize database easily. You can create, delete and update table easily with the help of this.
With the help of dropTable() method you can easily delete the table from database.
Its help you

MVC 3 Database First and Entity Framework 4.1: I cannot see the data in my database

I used Visual Studio 2010, MVC 3 and Entity Framework 4.1 (Database First) to create a web application using an existing database. In other words the structure of the database was used to generate the basic code for the models. I created controllers with "Controller with Read/Write actions and views, using EntityFrameword" as scaffolding option. However, I cannot see the data that was already in my database when I access the web application, and if I insert new data, I can see it using the web application, but I cannot see it in my database. I am now wondering where my web application is fetching and storing its data. It is as if a new database with an identical structure had been created elsewhere, but I don't know where.
By the way, I specified "New Data Context..." as Data Context Class when creating my first controller.
I suppose that you should start create Db (or another one scenerio to create new db and drop ex)
DropCreateDatabaseAlways<OhMyContext> initDb =
new DropCreateDatabaseAlways<OhMyContext>();
And after that
using (OhMyContext context = new OhMyContext())
{
initDb.InitializeDatabase(context);
}
and now you can use your db. it will create SQL server as defined config.
of course you should use your DbSet<T> as collections. but data will be modified (update, delete or insert) after context.SaveChanges().
gl.

Resources