entity-framework

MVC2 RTM - model binding complex objects using Entity Framework

I am new to MVC, and am really struggling with what I seems like it should be a very common scenario. I'm using MVC2 RTM, and the Entity Framework for my model objects. What I have working: An edit view for a parent object that contains a collection of child objects. The form displays all the editable fields for the parent, and iterat...

Determine source of a ConstraintException in an EF entity.

I have an entity class with a bunch of non-nullable string properties. If I try and set one of these to null, I get a ConstraintException and the message "This property cannot be set to a null value." Without setting tracker variable to the name of each property before assignment, is there a way I can determine which property assignmen...

1 to 1 Object Relations in EF4 Code First

I have a parent object book, and a property of that object is publisher. Everytime I ad a book, it is adding a new publisher, even if the publisher already exists. Can someone tell me how to add the book and instead of adding the publisher again, just reference an existing one? The code i am using is below... Thanks in advance! publ...

Entity Model Zero To One Should be One to Many?

Here is part of my Entity Model which I just generated from a MySql database. My question is why are the tables UserNotes and UserLoginHistory coming out as Zero to One. When I change them to many (collection of usernotes) I get the error: Error 1 Error 113: Multiplicity is not valid in Role 'user_notes' in relationship 'UserIdFKeyNo...

database actions select , update , insert and delete

Hi All: How i can make a decision to use Linq or Entity Framework as data access layer and business logic layer from performance viewpoint (execution time , roundtrips ). ...

Entity DB Adding New User and Other Related Data to DB

Hey. Nooby question but new with Entity. I am trying to create a new user object and some details in some additional tables which have a foreign key of the newly created user id. I've attempted to do this in one round trip. Do I have to add the user to the database first and then go back, set the userid's on the other objects and add t...

Selecting columns in entity framework data binding

Hi all.. I'm doing data binding with entity framework. I have three master-detail-sub models: Customers, Orders, and OrdersDetails. This would be run fine and data binding doing great: this.customerBindingSource.DataSource = context.Customers.ToList(); But sure that would return all columns. How can I return specified columns and sti...

Create One-To-One relationship between table and view in EF4?

Hello I have a table Item (ItemId int PK, Title vc, Description vc) I created a testing view called ItemView: SELECT * FROM Item. I added this view to my model, removed all the keys but the real key, added a 1-1 association, and mapped it, but I get 2 errors: The table/view 'dbo.ItemView' does not have a primary key defined. The key...

Entity SQL query with hierarchal relation

I want to use Entity SQL to query the elements of some subtype in my Entity Model. For instance... SELECT VALUE c FROM Persons AS c WHERE c is of (Customer) no problem meanwhile, but if I try the following query where Active is a property of Customer entity... SELECT VALUE c FROM Persons AS c WHERE c is of (Customer) AND c.Active == ...

LINQ to SQL & EF

Possible Duplicate: Entity Framework vs LINQ to SQL Hi, What is the use LINQ to SQL though EF is supporting the SQL Server? Moreover, suggest me when to use LINQ to SQL and EF ? ...

Entity framework - Modify a list of children objects

When I have a parent Entity hold a list of other entity (one to many relationship), I modify this list then call function to save the parent Entity. With the entities has removed from this list, is that the framework will delete them from database? And also the new entity has added to the list will be added to database? thank for your he...

Creating entities from stored procedures which have dynamic sql

I have a stored procedure which uses a couple of tables and creates a cross-tab result set. For creating the cross-tab result set I am using CASE statements which are dynamically generated on basis of records in a table. Is it possible to generate an entity from this SP using ADO.NET Entity framework? Cuz each time I try Get Column Info...

Entity Framework: Name Collisions (.NET MVC)

Hi, extremely sorry for writing here, I'm a php guy, been doing .NET MVC for like three days, although I had experience with C# some time ago. Anyways, I'm doing a simple website with shops and news stories. A news story could be either a global one, or tied to some shop. I use ShopId in the News table which can be 0. What I'm trying to...

Best way to implement a Notes Table for many entities Tables in SQL

i have many tables : customers, prospects, friends.. They all have some Notes. Question 1: Should i have one Notes Table shared with all the parent Tables. OR Should i have a NotesCustomer, NotesProspects, NotesFriends Tables ? Question 2: If the best solution is the first one then this general Notes table should then have a FK to th...

Is it possible to create an association between two normal fields in Entity Framework, thereby ignoring the primary key?

Hello fellows, I have the following situation between these three tables: Before I start explaining what I'm trying to accomplish here, let me clarify three things: I drew the model on EntityFramework, but this is actually the database view. Just assume that the fields type match between tables; I know that this database model suck...

Entity Framework 4 and Default Values

I might be missing something, but a SQL Server 2008 R2 database as generated by Entity Framework 4 is missing the default values I configured via the EF designer. Any ideas what I could be doing wrong? ...

'datetime2' error when using entity framework in VS 2010 .net 4.0

Getting this error: System.Data.SqlClient.SqlException : The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. My Entity objects all line up to the DB objects. I found only a single reference to this error via Google: http://ramonaeid.spaces.live.com/blog/cns!A77704F1DB999BB0!182.entry Af...

Can this be done with Entity Framework 4 ? If not, what can do this?

Hi folks, I'm making a simplistic trivial pursuit game. I'm not sure if (and then how) I can do the following with EF4 :- I have a table structure as follows. Table: TrivialPursuitQuestion => ID => Unique Question => AnswerId => AnswerType (ie. Geography, Entertainment, etc). Table: GeographyAnswer => ID => Place Name => LatLong ...

Ordering Entity Framework sub-items for EditorFor

I've seen http://stackoverflow.com/questions/3565249/ordering-sub-items-within-ordered-items-in-a-linq-to-entities-query which suggests that there is no way of getting the repository to return sub-items in an entity graph in a specific order. If that's right, any thoughts on how to order the items in an EditorFor ? i.e. //This works ...

Entity Framework function import: input parameters mapping

Hi everybody, Entity Framework allows to map the result of a stored procedure to an Entity easily. What I need is to map an Entity to input parameters, so that instead of context.SaveUser( user.FirstName, user.LastName, ... ); I can simply call it like this: context.SaveUser( user ); What I really want is to isolate possible schem...