Can't see my Entity tables in Add New Data Source… - sql-server

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.

Related

MVC3 Recreate Tables

I'm making a MVC3 C# application and I wanted to clear all the tables and basically start fresh. I went into the SQL Server Object Explorer and deleted all the tables that I was using for my models. Now I was hoping they would be created again and empty next time I build.. unfortunately that isn't the case. How can I get my application to recreate the tables?

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

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.

How to put Database Tables in MVC Models

I'm new in developing in MVC and I have some doubts in how to build the Models. I don't know if I must build them in terms of Database Tables or in other terms.
I have for example this 5 tables:
Domain
Category_Domains
Countries_Domains
Categories
Countries
How can i Build a Models to do actions in these Database Tables. Should I built the SQL commands to Insert, Delete and Update for each one of these Tables or I should do other thing than this?
Sorry if I not explain well.
The best advice I can give you is to look into the entity framework. Using this framework, you can create a data connection to your SQL database and the framework will create your model based on your table structure, including relationships.
Doing this will ensure your database is modelled correctly and kept in sync at all times

Resources