entity-framework

Can I receive a projection of an entity from the server?

I have an entity data model and a domain service (it may be a RIA service - I don't know) like this: [EnableClientAccess] public class MyService : LinqToEntitiesDomainService<NORTHWNDEntities> { public IQueryable<Categories> GetCategories() { return this.ObjectContext.Categories; } } From what I understand this...

Objectcontext and foreignkey-relationships in multi-tier webapp

Hi, I am creating a webapp using entity framework 4. As far as I can tell from extensive googling, it is best practice to create and kill the objectcontext when it is being used, and not let it live too long. So in my datalayer, I am doing something like: using (var context = new MyDAO()) { MY CODE } creating and killing the context ri...

Entity Framework inheritance association problem

Hi everyone, I am trying to resolve a situation I ran into when implementing EF with my project. I have absolved the table-per-type approach, in my case the ActionUpdate derives from the ActionHistory and that works fine. What I am trying to achieve is to derive the ActionUpdate from the ActionHistory, and to have a navigation propert...

Dynamically sorting and filtering projected Entity SQL results

I have the following query which I want to sort or filter using projected class names: List<CompanyInfo> list = new List<CompanyInfo>(); using (var db = new DbContext()) { list.AddRange( db.Companies.Include("Projects") .Select(row => new CompanyInfo() { Pr...

Global rename identity for enity.

All identities of entities in model have name "EntityNameId". How I can rename all identity to "Id"? ...

How do I use Entity Framework with MySQL Connector noinstall version?

Does anyone know any way to have the Entity Framework working with mysql connector 6.3/6.4 no install version? I can add the dll-s to my project, but I can't add the connection to the Entity framework because it doesn't see mysql. ...

EntityFramework Connection problem

Hello Everyone. I have a solution in Visual Studio 2008 with 3 projects. One Web Application and 2 class libraries. The entity framework model is in a class library and the start project is the web application. I used to have this problem: "The specified named connection is either not found in the configuration, not intended to be use...

WPF Cloned/Detached object edit problem - what is the standard ?

Hello, I am using an ObservableCollection to wrap some of my generated entity framework objects. When the user wants to edit some values , i am opening a popup windows that contains fields, and when the user changes and press save - the changes are saved to the database, and the binded controls are changes as it is an observablecollect...

Storage and Logical Model in Entity Framework

Could someone clear something up for me? As far as my understanding goes, the physical model describes how the data is represented in the context of a specific storage medium. The logical model is a representation in terms of entities and relationships, independent of any particular data management technology. How do these two work with ...

Entity Framework LINQ projection into custom type results in missing data

I have a many to many relationship between Contractors and SafetyCouncils. They are joined by a bridge table ContractorsSafetyCouncils which consists of ContractorId and SafetyCouncilId. These 2 columns form a composite key. This relationship is mapped correctly in EF4. The Contractor entity has the property: public virtual ICollection<...

How to design database with user editable/versionable content using Code First?

I an developing a page where users will be able to add and modify existing content, its not a wiki per sé but sort of, like SO's editing abilities. I am working with EF4 and the new Code First approach in the latest CTP, so what would be the best class design for this? my current guess is something like this: public class VersionableT...

Entity Framework filter on foreign key

Depot_ID is a foreign key in the database table Address. In my entity model i noticed that the foreign keys are not listed in the diagram var Address = db.ADDRESS.Where(a => a.Depot_ID == id.Value); This does not work as Depot_id is a foreign key in the Address table. What do I need to do to filter on this field? ...

How to perform updates in entity framework 3.5 within an SqlTransaction

I'm working on a plugin that gets loaded via IOC from a 3rd party data driver. The plugin and data driver both operate on the same SQL Server 2005 database, but the plugin focuses on a small subset of tables that have foreign key relationships to the tables that the data driver manages. My problem is that in some operations, the data d...

How can I take a picture of my database Entity Framework model for people to reference?

My company has made an Entity Framework model of the database with all of the relationships mapped out and I'd like to take a screenshots of that with all of the FKs included in it. But I can't seem to figure out how to take a screenshot that includes all of that information. Any advice? The "Export as Image" feature of Entity Framework...

Entity Framework + conditionally appended Where() clauses

This is driving me nuts. What am I missing here. I'm using EF and if I have code like the following: using (LexiconEntities ctx = new LexiconEntities()) { var query = from w in ctx.Words select new WordEntryDataModel { Word = w.Anagram, NumOfAnagrams = w.NumAnagrams.Value, Length = w.Lengt...

Entity Framework (POCO) + Unit Testing = Collection was modified exception

I have an app that uses EF POCO for accessing data. Everything works great, yet there is one problem with unit testing. Imagine two related classes: public class Brother { public virtual Sister Sister { get; set; } } public class Sister { public virtual ICollection<Brother> Brothers { get; set; } } The problem here is that if...

Automation vs Control - .Net Entity Framework 4 vs Custom Solutions

I've been a heavy user of .Net since its inception, but I have avoided using any of its ORM features, regardless of flavor. I have always been skeptical of tools which abstract CRUD, binding, validation, searching, etc. Some of this skepticism comes from painful, real-world experience; the rest of it comes from the innate desire to "own"...

I dont want to insert the PK val.But - Cannot insert explicit value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF.

I am using the Entity Framework to update my database. The Employee table has an employeeId primary key field. When I instantiate an employee object, the employeeId defaults to zero. I want to insert the employee object into the database, ignoring the primary key value of zero. Yet I get this exception; Cannot insert explicit value for i...

Make sure Entity framework always reads from database?

Hi! I have this applikation that is actually two applications, a webapplication and a console application. The console application is used as a scheduled task on the windows machine and is executed 3 times a day to to some recurring work. Both application uses the same Model and repository that is placed in a seperate projekt (class lib...

Working with nullable types in Expression Trees

I have an extension method to dynamically filter Linq to Entities results using string values. It works fine until I use it to filter nullable columns. Here's my code: public static IOrderedQueryable<T> OrderingHelperWhere<T>(this IQueryable<T> source, string columnName, object value) { ParameterExpression table = Expression.Paramet...