entity-framework

Why does Entity Framework not return a trimmed string for a nvarchar(MAX) field?

I'm currently working on a Silverlight application connected to a SQL Server 2008 Express database that is largely based on a demo on Brad Abrams' blog. (NOTE: The demo file at the specified link is actually a different solution that the one he shows on the live running application. The demo in the blog post uses Entity Framework, whil...

Entity Framework - get records in multiple tables using stored procedure

I am trying to get to grips with the Entity framework, and have a requirement to order results by distance from a point on the globe. I have decided on previous advice to do this using a stored procedure which I have successfully done populating a view. However I need to return multiple tables, which I understand I cannot do directly usi...

Rights-based security model (Winforms, EF)

We are developing a winforms CRM application with the use of ADO Entity Framework. For the security model we looked at role-based security but find it to sensitive to change. Our requirements are very complex since we need to define permission on a criteria. An example would be that "advisor" could only be modified by user X if the relat...

EF: load references after the context was disposed?

Hello everybody. I'm struggling with the ADO.NET Entity Framework. This is my ER-diagram: --------------------- ----------------- --------------- | GrandParentEntity |<-------| ParentEntity |<-------| ChildEntity | +-------------------+ 1 N +---------------+ 1 N +-------------+ | Id | | Id ...

Entity Framework, changing EntityKey leaves Entity as "UnChanged"

I have an entity with a status property that I would like to update. I would like to do the following: const int NEW_STATUS = 2; myEntity.StatusReference.EntityKey = new EntityKey("SetName", "KeyName", NEW_STATUS); When this is passed to the context, its state is "UnChanged", despite me changing the relationship! This means the save...

Where can I Find some Good Linq to Entities Tutorials?

I am getting started with Linq to entities and do not know where to start. Can you recommend some good tutorials online and some good books I can buy? ...

Binding Entities to a Windows DataGridView

I have an EF source that I'm binding to a DataGridView. The binding is happening programatically. However, the sorting is not working. So I decided to mess with some code and create an Extension Method, but it seems like its still not working. public static class BindingListEntityExtension { public static BindingList<T> ToBindingLi...

Extending IEnumerable to Return BindingList

In a previous question on Stack Overflow, I had run into an issue with returning an EF query to the DataGridView. Of course I'd run into an issue. However, I added an extension method that still has me baffled since it isn't working. It seems like it should, but for some reason it's not. public static class BindingListEntityExtension { ...

How to extract an individual item of an EntityCollection thru xaml binding?

Hi! I have a Contact entity that exposes a navigation proeprty for child Phone entities. Public Class Contact : Inherits EntityObject Public Property Phones() As EntityCollection(Of Phone) EndClass I want to Xamly retrieve the first phone of the bound contact. I tried the following but it doesn't work. Note: I also tried Phon...

Entity Framework - Autogeneration vs Manually Creation of Entities

You can refer to this post of mine. It is not the case that, someone will be able to generate perfect Entities from the database tables every time. If any entity is not looking perfect, how can I tweak it? And how should I tweak it? Or should I search for the flaw of relations in the Database, fix it first and then try to generate Ent...

JOIN/query accross separate entities.

What are the current options for querying and joining two different Entity Data Models? I've seen that it's possible to share a single model schema between multiple mapping and storage schemas, but it seems clunky and not encouraged. The other option I can think of is to query the entities separately and then join the linq objects, but I...

MySQL Data Provider - Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.

I'm having some difficulty with my Entity Framework context that is proving very troublesome to debug. I added a feature to my application yesterday that gave one of my entities an additional collection of child entities (called Models) and after updating one of my expressions to Include() that collection when I query for the parent obje...

Entity Framework - How should I instance my "Entities" object

I'm a total newbie at Entity Framework and ASP.Net MVC, having learned mostly from tutorials, without having a deep understanding of either. (I do have experience on .Net 2.0, ADO.Net and WebForms) My current doubt comes from the way I'm instancing my Entities objects. Basically I'm doing this in my controllers: public class PostsCont...

DataContext.Log equivalent in Entity Framerwork?

In Link-2-SQL, I can use the DataContext.Log property to see the exact queries that are getting thrown to SQL Server. Is there an equivalent to this in Entity Framework? Thanks Daniel ...

where to put the connection string in a n-tier app?

I've created a DAL using the entity framwerok. I've also created a business service layer and a presentation layer(web app). My common sence is telling me the connection string should by only in the DAL but the presentation layer needs the connection string too. So what's the best-practice for this situation ? Is there any way to have ...

keyword not supported data source

I have an asp.net-mvc application with the default membership database. I am accessing it by ADO.NET Entity Framework. Now I want to move it to IIS, but several problems showed up. I had to install SQL Server Management Studio, Create new DB, import there all the data from the previous .MDF file. Only thing left to do (as far a I know)...

Enterprise MVC Application Project Setup With Entity Framework

So I was looking at this site which shows a pseudo project setup for entity framework. I know this article does not use MVC but it did get me thinking. Would you guys have your "model" tier to include all of the Entity Framework references, entities, business rules, repository facade, interfaces, buddy classes for validation, and the d...

Entity Framework: EntityCommand automatically parsing and determine parameter types?

Hi everybody, Pretty new to Entity Framework I must admit, but I simply cannot believe that there is no built-in solution for this problem. Let's say I create an EntityCommand: EntityCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = commandText; And let's say the the commandText is something l...

Entity Framework T-Sql "having" Equivalent

How can I write a linq to entities query that includes a having clause? For example: SELECT State.Name, Count(*) FROM State INNER JOIN StateOwner ON State.StateID = StateOwner.StateID GROUP BY State.StateID HAVING Count(*) > 1 ...

Pass variable type to a method without enumerating

I want to be able to pass a variable type to a method, mainly so that I can pass an entity framework query to a method that will apply common includes of nested object. This is what I want to do... public Person GetPersonByID(int personID) { var query = from Perspn p in Context.Persons where p.PersonID = personID ...