entity-framework

What statements does Linq to entities support?

Does anyone know where I can get a full list of supported statements for linq to entities, this is statements that will be translated and run on the database...? ...

Using Entity Framework with MyIsam tables

Hi, Got a question about Entity Framework and MyIsam tables. My production database consists of MyIsam tables only. Often with a primary key like UserId and then a secondary KeyId that is auto incrementary. Since secondary auto incremantary keys are not allowed in InnoDb, and there will be ALOT of work to get rid of them before convert...

Entity framework: How can I use more then one context and stay synchronized?

Hi, I'm new with EntityFramework. My application has a pool of context object instances (Each context has 1 connection to the DB). The problem is that when I update an object (and calling SaveChanges), the data is updated in the DB and in the updating context but when I select from other instance, it gets the old data of the selected ...

Entity framework: How can I get the new object id (generated by DB sequence)

Hi, I have table with sequence and trigger so it creates new id when inserting it to the DB. How can I get the new object id, before calling SaveChanges()? I need this id for the links between the new object and other objects. I want to do it before calling SaveChanges because I want to have the option to rollback. Can someone solve...

Map a stored procedure to an Entity object and its child objects

Within EF4, it's pretty easy to map a stored procedure into an entity. I create the stored proc, Add it to the model, then do a Function Import and specify the parent entity. Now, the rub comes in that I want my stored proc to do "eager loading" of the children entities. In effect, I have a table Parents and a table Children, with a o...

.NET 4.0 Entity framework Error on Insert?

I don't know why it's is error on SaveChanges(), i search in google, some body say using EF, the database's table such have primary key, i have this, but still error. The error message is not enough clear,it just throws System.Data.UpdateException. The Code: public static void AddAccount(int _acc_id,string _name) { dataEntities de =...

Is it possible to prevent EF SaveChanges() from writing to DB?

I have service classes based on Entity Framework 4. I'd like to test them on a database filled with pre-generated sample data. The problem is: I would like the tests, whether passed or failed, to not actually touch the database, so that it may be re-used for other tests. Thus I'd like ObjectContext.SaveChanges to pretend that everything...

Error: The result of a query cannot be enumerated more than once

Call SP in EF 4.0 in following code: public IQueryable<Employee> GetEmployeesByFollowup() { var results = from p in this.ObjectContext.SearchEmployeeFollowup() select p; foreach (Employee p in results) { p.DepaermentReference.Load(); ...

What is the difference between Entity Framework and LINQ to SQL by .NET 4.0?

I was checking 2nd edition of Professional ASP.NET MVC and realized EF replaced LINQ to SQL. I am familiar to LINQ to SQL from the first book but I know nothing about EF. Anyway while reading the code, it seems like nothing has changed except the name. Same old repository, same old functions. I did a little research. I know LINQ is not...

Application of Entity Framework to scientific (numerical) processing program

Hello, I have a thought provoking question, in relation to the use Entity Framework (EF) to persist data. My (intended) application is not a typical LOB scenario where the standard CRUD operations are done on individual records. Instead, what I would like to use the data stored within my entities, create some Matrices by combining the ...

How to build a query by passing the columname and columnvalue as parameter using LINQ

Hi All, We tried using the below code snippet but showing the syntax error. var query = (from def in entity.Defect.Where("Owner == @0", "rochs") select def).ToList(); Thanks in Advance ...

Entity framework: Using transaction scope and querying

Hi, I'm using entity framework with oracle DB. I tried to use transaction scope (because I want the option to rollback): using (TransactionScope ts = new TransactionScope()) { ..... } The problem is that when I'm trying to query inside the using statement, an exception is thrown: "Unable to load DLL 'oramts.dll': The specified...

Refresh ObjectContext or recreate it to reflect changes made to the database?

I have a web service that exposes operations to and from a database. I'm using Entity Framework 4 for the DAL. I'm wondering what would be the best way to handle operations to and from the database. Would it be best not to keep alive an instance of the ObjectContext and instead create one for each operation done to the database? This se...

Get empty objects over WCF with entity framework

Hi! I've a WCF Service, that uses entity framework (with POCO objects). One methods returns a list of users. It was working correctly, but another method cannot insert anything because the database wasn't having "IDENTIY" setted on the primary key. Since I've done that, regenerate the EDMX model, I've a problem to get my list of user...

Best primary key format for large table

I'm developing an asp.net application that has some potentially large data tables. I would like to know what would be the best way to define a primary key. I know this has been asked before, but since this is for a specific situation, I think the question is valid. I'm using Entity Framework 4 on a SQL server 2008 database. What are th...

Encrypted columns with Entity Framework

Anyone figured out a good way to pull encrypted values from db through entity framework 4? I got a MySql db with some columns encrypted with des_encrypt and need to be able to get those values as easy as possible, and also of course, update and insert them. I think it's quite strange there doesn't seem to be in built support for this i...

Retreive all Children and their Children, recursive SQL

Consider the following rows in a database: Id | Parent __________________ 1 null 2 1 3 2 4 3 5 null 6 5 Each Id that has a null Parent is the "Owner"/"Super Parent". What would be the best approach, performance wise, to collect the parents and their children ? Shoul...

How to update Entity but insert new row on SaveChanges?

I have Entity1 with properties Entity1.id= 1; Entity1.a = 10; Entity1.b = 123; Entity1.c = 231; I wan't to change properties but to insert a new row on context.SaveChanges() not to do update for existing id. I tried to set Entity1.entityKey = null but it fails. Any ideas? Thanks. ...

get the id of a new record in SavingChanges event on the entityframework

Hi, Im tring to implement some generic logging in the entityframework 4.0 using the SavingChanges event in the entity context. I want to record details about any create/ update and deleted records including the id of the record being changed (which is always an int identity field). During the update and delete processes I can get the ...

Copy object cause property changed on the object copied?

Entity Framework 4: Following code cause entity Employee property changed: var results = from p in this.ObjectContext.SearchEmployeeFollowup() select p; List<Employee> temps = new List<Employeer>(results); But I don't want the property changed event fired at this time. How to resolve this issue? ...