entity-framework

Map relationship with Entity Framework

Maybe im just an idiot, but I am having serious issues mapping relationships with the new entity framework. When using LinqToSql, you would just right click the table, add association, select the two tables, and selected the property from each table the association was based on. End of story, it worked perfectly. Using the entity fram...

Replace Linq to Entity value in Projection

I want to relace a value retrieved from a L2E projection to an expanded string. The table contains a column called Status which can have a value "0" or "1" and in my L2E I have var trans = from t in db.Donation select new DonationBO() { Status = t.Status }; What I want is to return e...

A SQL 2005 Database Design and Entity Framework transaction conundrum

Hello. I have a database design issue that I am trying to also fit into Entity Framework. Its complex, I have inherited it and its too late to make drastic changes! I want to draw on others wisdom before I make a decision about how to go forwards...my original post was much longer, but I think the business logic details are probably not...

Simple relational problem

Hello I'm using entity framework with 3.5 sp1, and I've come across a strange problem. I have a 1 to many relationship and I cant seem to add a value for it. I have a table "Bookings" and FK in table "Users" (nullable) and FK in table "BookingObjects" so: Users 0..1 <-> * Bookings * <-> 1 BookingObjects Table: Users Entity: User S...

Using Entity Framework generated classes in Business Logic Layer

I have a ASP.net (C#) project that is using a three layer architecture. I started to use Entity Framework in my DAL and the question is to what extent classes generated by Entity Framework can be used in the Business Logic Layer? It is a good idea to use them directly or should i create my own business objects and map to them from Ent...

Asp.net MVC-How to add order-orderDetails objects using EntityFramework?

I have an application that uses one-to-many relationshipped objects like oreder-orderDetails, vith EntityFramework. I want to use a view, that make it possible to add a new order with some orderDetails objects. I can create a strongly typed view, that returns an order object wich has a List orderDetails property, but can't populate the...

Best way to check if object exists in Entity Framework?

What is the best way to check if an object exists in the database from a performance point of view? I'm using Entity Framework 1.0 (ASP.NET 3.5 SP1). ...

RIA services, EF and stored procs

I have this problem for 2 months now How can I use stored procedures whith RIA. I was using LinqToSql and everithing works fine. I've made an class in designer and mapped it to a SP. Now in EF I saw this ComplexTypes I've imported son SP with result in ComplexTypes. But in DomainDataSource are not appear. OK. But how can I use the...

How to set an FK column value without retrieve it

Hi, i want to set a new value to my entity objects FK column, but i cant find the property to set. I dont want to get record from db. I have a db like that Db Tables: Concept ConceptType -Id (PK) -Id(PK) -Name -Name -ConceptTypeId(FK) (ALLOW NULL) Code: Concept conceptToUpdate = new Con...

Change Entity framework database schema at runtime

In most asp.net applications you can change the database store by modifing the connectionstring at runtime. i.e I can change from using a test database to a production database by simply changing the value of the "database" field in the connectionstring I'm trying to change the schema (but not necessarily the database itself) with en...

Which approach to create the data access layer has the highest performance?

I have to create a very high performance application. Currently, I am using Entity Framework for my data access layer. My application has to insert some communication data almost every second. I found that Entity Framework is slow; it has about 2 seconds delay to finish the SaveChanges() method. I was thinking I have the following optio...

Using Entity Framework with different version SQL Server

Hi all, I think most of you may work with the latest version of SQL Server and deploy it to the target machine which have a relative old version on it. Like using SQL Server 2008 on production machine and SQL Server 2005 on target server. While working in such situation with Entity Framework, It made me a little bit frustrated. I desig...

OptimisticConcurrencyException -- SQL 2008 R2 Instead of Insert Trigger with Entity Framework

Hi, Using a SQL 2008 R2 November release database and a .net 4.0 Beta 2 Azure worker role application. The worker role collects data and inserts it into a single SQL table with one identity column. Because there will likely be multiple instances of this worker role running, I created an Insert Instead Of trigger on the SQL table. The...

What is equivalent GetPropValue<T> method in L2E ?

Hi people. I´m have a problem using EF for my data model. I have this code in my method: listaPaginada = sortOrder.Equals("asc") ? _cadastroServ.SelecionaNotasFiscais(idParceiro).OrderBy(i => i.GetType().GetProperty(query)) : _cadastroServ.SelecionaNotasFiscais(idParceiro).OrderByDescending(...

Entity Framework v4 - what's the difference between POCO vs Code-Only ?

Hi folks, i'm under the impression that EF with POCO: allows you to map your own POCO's to the entities on the model (.edmx). EF Code-Only: no edmx / model designer (ie. CSDL/SSDL/MSL (collectively EDMX) metadata). Still POCO's but the mappings, relationships, navigation, etc are all manually coded (hence the code-only, description). ...

Resources for learning the ADO.NET Entity Framework CTP 2

Hello all, So here the ADO team announce CTP 2 of the Entity Framework. What resources are about to help me learn this? I've seen this which nicely describes earlier versions but it's the new version I'm specifically interested in. Thanks! ...

Need help with designing a query in ELinq

This is my query: Dim vendorId = 1, categoryId = 1 Dim styles = From style In My.Context.Styles.Include("Vendor") _ Where style.Vendor.VendorId = vendorId _ AndAlso (From si In style.StyleItems _ Where si.Item.Group.Category.CategoryId = _ categoryId).Count > 0 _ ...

Saving a single entity instead of the entire context - revisited

I’m looking for a way to have fine grained control over what is saved using Entity Framework, rather than the whole ObjectContext.SaveChanges(). My scenario is pretty straight forward, and I’m quite amazed not catered for in EF – pretty basic in NHibernate and all other data access paradigms I’ve seen. I’m generating a bunch of data (in ...

Eager Loading on tracked items?

I have an element bound to an entity (Contact) that exposes some navigation properties. I want, that on some action (i.e. a "Load children" button), the Contact should load for all its children and grand children like I can do with an ObjectQuery.Include before the execution; example (pseudo): DirectCast(element.DataContext, Contact).S...

EntityFramework or LinqToSql Entity Namespace

Hi, I want to specify entity namespace based on my domain structure. Usually like that : Infrastructure.SqlServer Customers (NS : Infrastructure.SqlServer.Customers) Customer Address Products (NS : Infrastructure.SqlServer.Products) Product ProductVariant ProductCategory How can i do that with LinqToSql or EntityFramework ? It...