entity-framework

Keep EntityObject from changing into Added state (Entity Framework)

Stupid question maybe, yet still. public class Foo : EntityObject { public Bar Bar { get; set; } // navigation property } public class Bar : EntityObject { // whatever } // code var myFoo = Foo.Create(); // detached state after this line var myBar = LoadMyBarFromDatabase(); // Bar comes from DB myFoo.Bar = myBar; // myFoo.Enti...

We are using EntityFrame work in a singleton class ? - Not reflecting the DataBase changes in the front End

Our application is using Entity Framework(.net 3.5) and singleton . When i update in the back end through procedure. It is not reflecting in the entity context. I tried with refresh - But it is not refreshing Foreign Key. How to refresh the entire context in Entity Framework ? ...

Using EF 4 on .NET 3.5 SP1

Hi guys, I was using the latest EF 4 bits in Visual Studio 2010 RC and have fallen in love with it. However, I have to develop a small web application using .NET 3.5 SP1 (VS 2008) for work... I was wondering if it was possible to somehow utilize EF 4 in .NET 3.5 SP1/VS 2008. Regards, Karan Misra ...

How would I best address this object type heirachy? Some kind of enum heirarchy?

I'm curious as to any solutions out there for addressing object heirarchies in an ORM approach (in this instance, using Entity Framework 4). I'm working through some docs on EF4 and trying to apply it to a simple inventory tracking program. The possible types for inventory to fall into are as follows: INVENTORY ITEM TYPES: Hardware P...

ADO.NET Entity Model and LINQ

Hi all I'm using an ADO.NET Entity Model which I'm trying to query using LINQ. The problem I'm having is that I can't specify the where clause as I'd like. For instance, consider the following query: AccountsDM db = new AccountsDM(ConfigurationManager.ConnectionStrings["PrimaryEF"].ConnectionString); var accounts = from a in db.Accoun...

WCF Data Services implementation strategies.

Microsoft has done a savvy job of not outlining the actual place for data services in the wonderful world of SOA/Web dev. So my question is are WCF Data Services designed to be used via external clients? Has anyone ever heard of someone using them on the server side (i.e. data base access for web service)? Simple scenario a general ...

The specified type member 'EntityKey' is not supported in LINQ to Entities

I have 2 Entities "UserProfile" and "Agent", they are 1-many relationship. I want to do a query to get a list of Agents by giving the userProfileEntityKey. When I run it, I got this "The specified type member 'EntityKey' is not supported in LINQ to Entities" error. public IQueryable<Agent> GetAgentListByUserProfile(EntityKey userProfil...

Internal classes with ADO.NET Entity Framework

I'm using Entity Framework for creation of my Data Access Layer and I want for all of my classes to be internal. I know it is possible to manually assign it in the designer for each class. UPDATE I found that my initial statement But looks like it also requires to set internal modifier for each single property in every class! I hav...

Linq to Entities strange deploying behavior.

Hi I started building apps with this technology and I am facing a weird problem... on some machines I need to add theese lines to the app.config to get to work: <system.data> <DbProviderFactories> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MyS...

LINQ query for tag system: Matching any of several tags?

I am just getting started with LINQ. I am creating an Entity Framework app that uses the canonical Post and Tag model. A Post contains an ID, Text, and Tags, and a Tag contains an ID, a Name, and Posts. A previous thread on StackOverflow showed me how to query for a Post that matches all Tag objects (A and B and C) in a search list. Bu...

EntityFramework how to Override properties

I've just started using EF in VS2010. That thing is just amazin'. I frankly can't understand something. For example I have EntityType with property, they generated from database structure. Now, I have to simply override that property in my code. I don't need to save value of the property back into DB, but everytime when it gets read fr...

Stop propagating deletes

Is it just me or is anyone else finding EF very difficult to use in a real app :( I'm using it as the data layer and have created custom business objects. I'm having difficulty converting the business objects back to EF objects and updating/adding/deleting from the database. Does anyone know a good, simple example of doing this? Actual...

Idiomatic default sort using WCF RIA, Entity Framework 4, Silverlight 4?

I've got two Silverlight 4.0 ComboBoxes; the second displays the children of the entity selected in the first: <ComboBox Name="cmbThings" ItemsSource="{Binding Path=Things,Mode=TwoWay}" DisplayMemberPath="Name" SelectionChanged="CmbThingsSelectionChanged" /> <ComboBox Name="cmbChildThings" ItemsSource="{Binding...

How to create an Entity Framework model from an existing SQLite database in Visual Studio 2008?

I've installed the System.Data.SQLite ADO.NET Provider from http://sqlite.phxsoftware.com/. I can connect to the database from within Visual Studio, I can open table schemas, views etc. I'd like to use an existing SQLite database to create an Entity Framework model in Visual Studio 2008. When I try to create a new ADO.NET Entity Data M...

ADO.net, Check if ObjectContext is writeable

I have an embedded database in an asp.net mvc project. If I try to write to the file, I sometimes get a write failed exception because the SQL Server can't write to the file. How can I check an ObjectContext, if its writeable, without actually writing something to the database? ...

How to get a reference to superior object from Entity object

How to get a reference to superior ObjectContext from EntityObject class? ...

ASP.Net RADs: Dynamic Data alternatives

Hi Guys!, We have a set of tables and views that merely store some config data for embedded devices. this schema is change-prone and do not really required lots of logic, beyond some validation rules. so we considered using a RAD tool for maintaining these CRUDS. In first stage: Dynamic Data But the community size, books absence and t...

How to create a Linq To Entities expression

HI, I'm using Linq To Entities and I'd like to convert this return db.Products .Where(p => p.idUser.Equals(id) && p.Category.Genre.Any(g => g.visible)) into something like Func<Genre, bool> expr = g => g.visible return db.Products .Where(p => p.idUser.Equals(id) && p.Cate...

How do I get the entity framework to work with archive flags?

I'm trying to create a set of tables where we don't actually delete them, but rather we set the archive flags instead. When we delete an entity, it shouldn't be deleted, it should be marked as archived instead. What are the programming patterns to support this? I would also prefer not to have to roll out my own stored procs for every t...

ADO.NET (WCF) Data Services Query Interceptor Hangs IIS

I have an ADO.NET Data Service that's supposed to provide read-only access to a somewhat complex database. Logically I have table-per-type (TPT) inheritance in my data model but the EDM doesn't implement inheritance. (Limitation of Data Services and navigation properties on derived types. STILL not fixed in .NET 4!) I can query my EDM ...