entity-framework

Save files in database with entity framework

I have an ASP.NET MVC solution built on Entity Framework with Microsoft SQL Server 2008. I need to create a function that lets my users upload files. What I would like is: A solution that uses the Entity Framework to store files in the Database A solution that detects and prevents from uploading the same file twice via some kind of h...

Linq OrderBy breaks with navigation property being null.

Working with four tables. Users -> has basic user info including a userid and a departmentid (int) Groups -> basic group info including a groupid GroupsMembers -> table that has the relationship between a group and it's members, many to many relationship, so groupid and userid are the columns Departments -> basic department info includi...

How to save child relationship entities in the Entity Framework

I have an Entity Framework v1 project. I have two entities (Roles and Permissions), which have a many-to-many relationship with each other. I pass in a object to be saved (through a WCF call, I do not create it from a context myself), which has new entries in the many-to-many relationship. I use "context.ApplyPropertyChanges" to upd...

Entity Framework - C# or VB.Net

My company is tossing around the idea of using the Entity Framework when it comes out with .NET 4. We are currently a VB.NET shop, but have some interest in switching to C#. Is there any major arguments for or against such a move? Does EF with C# hold any advantages in performance, coding ease, etc over VB.NET? Thanks for your thought...

Is there a specific performance issue with Entity Framework + GUID PKs?

My company has a basic SOA, using Entity Framework for database access. One of our services must interface with a legacy database which uses uniqueidentifier primary keys in the database. Performance is good during unit and integration testing. However, under load, the affected service starts to produce a backlog of queued requests. Thi...

Saving Data to Relational Database (Entity Framework)

Hi, I'm having a little bit of trouble saving data to a database. Basically, I have a main table that has associations to other tables (Example Below). Tbl_Listing ID UserID - Associated to ID in User Table CategoryID - Associated to ID in Category Table LevelID - Associated to ID in Level Table. Name Address Normally, it's easy fo...

Is it possible to retrieve connection string inside DDL generation template in VS2010?

I am playing around with creating a T4 template for the "DDL Generation Template option" (model first) process in Visual Studio 2010 RC. Is it possible to retrieve the connection string that is associated with that process? If I right click on the .edmx file and choose "Generate Database from Model..." I have the option of choosing a da...

Instructing Linq to Entities to Parse the Result of a Function, Not the Function Call

I have an function outside my EDM that I would like to include in some of my Linq to Entities expressions. The function returns an IEnumerable of Int. An example of how I might use it is: context.Employees.Where(e => GetValidEmployeeIds().Contains(e.EmployeeId)); The function GetValidEmployeeIds is the function that is returning the I...

How to Add an Entity with a Foreign Key through EF with Ria Services?

I have two tables in my database: Books and Categories. In my EDMX I have generated classes Book and Category, and correspondingly BookSet and CategorySet. I created BookService and can access it in my SilverLight code via BookContext. Through BookContext I am able to load a list of all books. My problem right now is I am trying to a...

What is the actual benefit of ADO.NET Entity Framework?

I was reading this article about ADO.NET Entity Framework and found it to be very interesting though in the first shot I could not decipher many things. I am reading the article again in order to fathom the real logic behind this. a) A question cropped in my mind is why we need an ORM framework (in general)? b) And among other ORM fra...

Using Entity Framework with repository pattern in WinForms MDI

Hi, We are about to start up a new project similar to a previous one. I could just copy the old design but I am not all too satisified with the old design. It is a "standard" business system (sales,stocktaking,warehousing etc) built ontop of .Net 3.5 (Winforms MDI) with Entity Framework in the backend. All forms inherit from a basefo...

Sorting an asp:ListView bound to an EntityDataSource

I have an asp:ListView control on an ASP.NET page. It is bound to an EntityDataSource which is setup this way: <asp:EntityDataSource ID="EntityDataSourceOrders" runat="server" ConnectionString="name=EntitiesContext" DefaultContainerName="EntitiesContext" EntitySetName="SOrder" Include="Address" EnableD...

ADO.NET Entity Framework Hierarchy type Inheritance Error 3032 Workaround??

I would like to implement a Hierarchy Type Inheritance ... i.e. Cars to BMWs ... Cars would have CarTypeID that is associated with CarTypes. I would like CarTypeID to be the discriminator column. Unfortunately, I cannot do this in ADO.NET Entity Framework. If I would like to keep the association, how am I able to achieve this? Has an...

Entity Framework Code Generation with Indexes

Is there a way to tell .NET 4 ADO.NET Entity's SQL Generator to create indexes for a specific column? ...

How to enable dropdownlist editing of values in an MVC View

Hi, The class that's returned to the view has several enum values from other tables: class Person{ int id; enum Rank; enum Status; } In the 'edit' View I would like to have a select box with the selected value so the user is able to change to another enum value. I get the enum values into a ViewData: <%= Html.DropDownList("Rank")%...

EF4 POCO (not using T4): Mapping and metadata information could not be found for EntityType...

I have a pretty simple console project with an entity model (containing two simple entities), two handmade POCOs and a handmade Context class. The program fires a simple query against the DB and everything including LazyLoading works fine. The problem: As soon as i add another Entity data model (even if i add an empty one), the calls t...

Looking for a basic example showing the use of Entity Framework with a WCF service

Can anyone point out a sample or two that demonstrate the use of Entity Framework and a WCF service? My data will be stored in SQL Server 2008 and accessed via a WCF service. I'd like a basic sample that shows how to build the data model using the WCF service and how to update the data when changes occur (also via WCF). Thanks! ...

ObjectDataSource and EntityDataSource Viewstate comparison

Hi, does anyone know if the ObjectDataSource is any more efficient in Viewstate use compared to EntityDataSource? I was reading Programming EF by Julie Lerman and she does warn that the EntityDataSource relies heavily on the Viewstate for change tracking. She seems to recommend instead to use ObjectDataSource but this control must also...

Linq to entities multiple WHERE clause &&

In the code bdehind && syntax does not work, any ideas? Entities ctx3 = new Entities(); var uniqueQuote = from quot in ctx3.Quotes.Include("aspnet_Users").Include("Enquiries") where quot.Enquiries.EnquiryId == selectedEnquiryId && quot.aspnet_Users.UserId == currentUserId orderby quot.QuotePrice select quot; Error 2 Del...

Returning Entity Data Model Entities as JSON data

I noticed people wrote about this circular reference problem quite a bit before but no solution was ever posted. I'm talking about this error: "A circular reference was detected while serializing an object of type 'DocInvoice.Models.Clients'." Has anyone tried serializing it to JSON with Json.NET library? If I have Linq to entities q...