.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Many-To-Many table relationship and model.edmx

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :ASP.Net
Hello,I'm having a weird problem with the database model as it seems. I have 3 tables (posts, taggedpost, tags) and when I create the model the relationship is correctly identified as a many-to-many but the linking table is gone.Instead, VS2010 creates only 2 tables, and maps 'tags' as a "Navigation Property" of 'content' and vice versa.So problem is, I need to query for posts that have a specific tag. The best I have gone so far is to query for all posts that have at least one tag and fetch them then programatically filter them, but I want the optimal which is to select them all at once.

View Complete Post

More Related Resource Links

Entity Data Model and database view returning the same columns as there are in a table


When adding a stored procedure into the Entity Data Model I can select whether the procedure returns a scalar, a (new) complex type or one of the entity types I already defined. 

How do I do something similar for a view?

I mean assuming I have a view like this

CREATE VIEW FilteredFoos as SELECT Foo.* FROM Foo join ... WHERE ...

(that is a view that implements some involved filtering, but returns all columns from one table) how do I add it to the project so that I can use the entity set, but get the Foo objects, not some new FilteredFoo objects.

var foos = myDB.FilteredFoos.Include("Bar").ToList();

foreach (Foo foo in foos) { ...

Thanks, Jenda

Model Binding the values in an HTML Table back to Controller / Model


Currently, I am working with ASP.NET MVC1 and am still learning about Model Binding and how values from a View are passed back to the Controller / Model. Specifically, I want take an existing Model, create a Table and populate the Rows of the Table, allow the user to edit some fields and pass it back.

In my example, I have a Class called "Ingredient" which has 4 public accessors:  Name, Barcode, Amount, and Unit

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcACE.DomainModel.Entities.Ingredient>>" %>

<% using (Html.BeginForm("SubmitOrder","MyController"))
{ %>

<% if (Model != null)
foreach (var item in Model)
{ %>
<td><%= Html.Encode(item.Name)%></td>
<td><%= Html.Encode(item.Barcode)%></

update a single table in edmx file


I'm working on the big project who has edmx file with lots of table. I want to update a table from DB. But when I update the edmx file, it  also refresh the other tables from DB. How do I update single table?

Add new record to a sql table that has a foreign key relationship using infopath form



it's me again.

i want to know how can i add new records to a sql database table that has a foreign key relationship with another table using infopath form.

i have created a blank form based on database

i have all my fields and the "add new" button already in the form.

i have the username and the userid filled in automatically when the user opens the form.

when i fill in the form with new data and click submit. it gives me this error:

Field or group: BE_CODE
Error: Only integers allowed

this "BE_CODE" field has to be filled in the database table, it can not be null. but it must not be filled in by the user it self. and it is a repeating table so it can not be auto increment.

how can this field also be filled in the database table?

What is the maximum number of records in a table which can be used to build/apply a model


Dear All,

I am building an association model , if my nested table records is more than 1 lac, model is failing.

Even same while applying the model also. Server's RAM size is 16GB.

Please can you suggest the maximum number of records that can be handled?

Thanks in Advance

How to specify ForeignKeyName for the relationship between fact table and dimension table?


The ForeignKeyName attribtute of a relationship is greyed and empty when I edit a relationship of a data source view in SQL Server 2008 BIDS.  How can I edit it?

Differences between SQL Server database definition and dynamyc data .edmx model


I am trying to customize a ForeignKey_Edit under a different name but I am having a problem with this: If I am listing one of the entities I have 4 columns that appear as links. My guess is that they are the Foreign Keys because they are the same fields listed as DropDownLists on top of the page.

One of this fields is the one I am trying to customize but if I use the UIHint attribute or property I got an error message saying that the columns can't be used as a Foreign Key because it isn't  a Foreign Key, but it is.

I have checked the database definition and in it the column appears as Foreign Key but in the Dynamic Data .edmx model appears as a simple field because it doesn't show the small key on the left icon. Only primary keys have the key.

Is this a bug or am I going the wrong direction?


Help: populate Html.DropDownList from table data? [Linq to SQL model]


I have two tables, Users and Roles.  The roles table is a reference table for the different roles of my site (RoleId and RoleName columns). The Users table contains profile data for each user, including a RoleId column that is FK'd back to the Roles table [RoleId].

Both tables are in a Linq to SQL model.

I have an edit page created which lists all the profile values of a user.  The edit page inherits the User model.  One of the editable values is the RoleId field.  I want to set this up to be a drop-down list that contains items labeled using the RoleName column of the Roles table, and matched with values of RoleId.

How can I achieve this?

Recovery Model Indicator - Which system table?




I hope you can help as I am really scratching my head on this one.  I am pulling together an assessment of the Disaster Recovery readiness for an organisation I am working at.  Part of the assessment I am doing is the recovery model of each of the databases.


I have scripts that are already pulling lots of data from 40+ servers and 500+ databases.  However, I cannot seem to find anywhere within the MASTER or MSDB or the database itself where the Recovery Model flag is held.  Obviously I can right click on the database and click properties and it is there, but I need to automate this task (as it will probably be a weekly assessment).


I have checked sysdatabases and almost every other table, but nothing obvious as to where this flag is.


Any ideas? 

Database Table E-R Entity Relationship Layout - please make suggestions and/or improvements ?


Not quite sure where to post this, but need some help defining a schema and E-R modelling, I'm not sure if I'm maybe making it too complex... 15 Tables in total right now




I have a store which Buys, Sells and Repairs - Laptops and Mobiles and Video Game Consoles and Printers.

This is a walk-in store, so customers can pay cash (and not have their details recorded) or they can pay by card. 


When buying therefore, if ordering via the Internet, customers will have their details recorded and added to the database, but if buying in the store, customers are unlikely to have their details recorded when buying unless they are making a return.

Customers will always have their details recorded when arranging a Repair.


I think I may need separate Orders and Sales tables, because Sales may be connected through an EPOS system, but Orders refers to internet orders, I'm not quite sure about this just now.


All items marked with * denote foreign keys.

So far I have the following table layouts, I'm sure I have missed something:




How to map an Entity framework model to a table name dynamically


I am working in MVC 3 with entity frame work so I am using List, create, edit and details page by razor templates of csHTML5.

But I have found one problem while creating a templates from my company model which Company table available in my existing database which I cannot change.

So all related controller and View has been created along with context, but Problem is comes that created entity framework structure is expected tables “Companies” but in my case I have table with company. Below

SQL 2008 create table relationship design failure

i want to make three tables and relationship on design time. Cutomer has many orders and each order has many items. CustId is primary key for Customer table, OrderId and CustId are primary key for Order table, OrderDetId and OrderId are primary key for OrderDet table. Customer and Order tables has relationship one to many by CustId, Order and OrderDet tables has relationship one to many by OrderId. I can not make this on design time. gettting error on SQL 2008 "The Column in Order table do not match an exisintg Primary or Unique key constrains."

How to update .edmx and domain service automatically? if any changes occur in View Table


I have a Age_Group Table in which its values change frequently and even I created View table. Based on Age_Group Table row's value which represent as columns in View Table. If Age_Group row's value change, new row occur or delete the rows based on that the View table is displayed. I am taking these View tables in .edmx and set domain service for that .edmx.

My query are:

Can I update the .edmx and domain service automatically? if Age_Group row's value change.

If yes, please tell me the way.


An Entity Relationship Diagram Example

An Entity Relationship Diagram conveys a lot of information with a very concise notation. The important part to keep in mind is to limit what you're reading using the following technique:

Choose two entities (e.g. Company and Employee)
Pick one that you're interested in (e.g. how a single Company relates to employees)
Read the notation on the second entity (e.g. the crow's feet with the O above it next to the Employee entity).

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

Insert value using Table Value Functions

a real gem in Sql Server 2008. mostly people still using Stored procedure may be they shifted to SQL Server but they are not using TVF right now.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend