entity-framework

ADO.NET Entity Framework and WCF Service

I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables with foreign key relationships. How can I send these entities down to a Windows Phone 7 client? I have created a WCF Service (using WShttpbinding),with the method... public List<LocationCity> ListCities() { var dc = ObjectFactory.GetInstance...

Creating UI and database dynamically, what is the best approach?

I have a requirement in which in order to make an application extensible and reusable, I have to create a provision through which a user would be able to provide a business object structure (the fields, their types, etc.) through an XML file and using that structure the UI (i.e. the controls and the complete page), the data updation meth...

EF Takes Forever to Generate this Query

I have a parent-child table relationship. In a repository, I'm doing this: return (from p in _ctx.Parents .Include( "Children" ) select p).AsQueryable<Parent>(); Then in a filter, I want to filter the parent by a list of child ids: IQueryable<Parent> qry; // from above List<int> ids; // huge list (8500) var filtered = fr...

Entity Framework - what's the difference between using Include/eager loading and lazy loading?

I've been trying to familiarize myself with the Entity Framework. Most of it seems straight forward, but I'm a bit confused on the difference between eager loading with the Include method and default lazy loading. Both seem like they load related entities, so on the surface it looks like they do the same thing. What am I missing? ...

Entity Framework 4 exception not being thrown / caught

I am connecting to a MySQL database from Visual Studio 2010 using Net/Connector. This is the entity framework 4 linq query: int timeThreshold = 5; DateTime cutoffTime = DateTime.Now.AddMinutes(-timeThreshold); try { using (var context = new myEntities()) { var un...

WCF with Entity Framework Error

Error: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection. I am trying to create a WCF service with Entity Framework (VS 2010, .NET 4). When I run it, I get the above error. I read something about editing the T4 template, but it appears that it already has [DataContractAttri...

EntityFramework "System.Data.EntityClient.EntityConnection.get_ServerVersion"

I am a newbie to ADO.net entity framework. I added 3 tables from the database and tried to query, base.CreateQuery gives exception "an item with the same key has already been added". Validate doesn't show any message either. FISSEntities SecurityMastercn = new FISSEntities(connectionString); var vwCadis = from cusip in SecurityMa...

How can I create a DropDownList?

I have two tables: Area and Boss. An Area has a Boss, it has a foreign key relationship of Area.IDBoss and that is Boss.ID. I hope I'm explaining my question properly. :P As of now I can manually type in a number in the textbox and it saves correctly, I can also display the name correctly because I'm using Entity Framework, something l...

Confused about navigational property/reference in Entity Framework

I'm trying to learn Entity Framework and I'm confused about navigational properties. I have a table named tblUser. It has a column named ManagerId which is has a self referencing foreign key to the UserId column. I've added this table to my EF model and I now have three "links" in my table entity properties: tblUser1 (type: EntityCollec...

Get EntityKey without loading referenced Entity

Hi, is it possible to get entity key from EntityReference property without loading it? I tried: entity.EntityKey.EntityKeyValues[0].Value But if referenced entity isn't loaded by EntityReference.Load() method, EntityKey property is null. Thank's a lot! ...

Why doesn't EF 4 generate association for FK relation to column with unique index?

Hi all, I have run into a scenario where Entity Framework 4.0 does not generate an association to an entity backed by a table having a unique index, and I am wondering why. The basic setup is this: Let's say I have two tables in SQL Server 2008 R2 and a foreign key relation: CREATE TABLE [dbo].[User]( [Id] [int] IDENTITY(1,1) NO...

Composite foreign key referencing unique constraint in Entity Framework designer - does it work?

Hi, I'm customizing a COTS product with a rather complex table structure and I'm running into an issue where Entity Framework doesn't seem to know what to do with a foreign key relationship. Here's an example: Order Id OrderDetailId Foo Bar OrderDetailId is a foreign key that references OrderDetail.Id, OrderDetail.Foo2 (combined as ...

How do I bind an Entity Object to WPF TextBox?

I feel like I'm missing something very obvious here but I can't get basic binding to work with objects from my EDM. Here's my xaml: <TextBox Text="{Binding Path=receipt.STATUS}" Height="23" HorizontalAlignment="Left" Margin="371,276,0,0" VerticalAlignment="Top" Width="120" /> Here's my View code-behind: public MainWindow() { ...

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

I am using the latest development version of the connector - 6.3.3 beta to connect to a mysql database via the Entity Framework 4 in VS2010. I have the following Linq statement which uses a TIMESTAMP column - createdDate - in the query. Here is the code: int timeThreshold = 5; DateTimeOffset cutoffTime = DateTime.Now.A...

ASP.net 4 Dynamic Data Many-to-Many with extra columns

I'm using ASP.net 4 to create a Dynamic Data site. I have a Many-to-Many relationship as described here: http://msdn.microsoft.com/en-us/library/dd742359.aspx It works fine when my middle table only has the foreign key columns of the parent tables. This is a customer<->products setup, where multiple customers can have multiple products....

Entity Framework (3.5) - Reject Changes

I have this service which is Singleton and Single threaded and serves bunch of low volume clients. It uses Entity Framework and Data in SQL Server. If any one of the client's request to Save Data fails, all the subsequent requests are being failed as every time it is trying to save the original failed data object. Is there is any way...

Self Tracking Entities - Deleting from Navigation Property does not set state to 'Deleted'

In the constructor of each of my POCO's I have this: this.StartTracking(); To ensure that tracking is turned on for every instance of one of my POCO's. I have an Entity A which contains a TrackableCollection of Entity B. When I load my instance of Entity A like such: using(MyContext ctx = new MyContext()) { entityA = ctx.EntityA....

Entity Framework - Query against database directly

Hi, I'm new to Entity Framework so please excuse if the answer to this question is obvious. We have few databases with thousands of tables in them. Most of these are data tables, that means each data update process might add or remove tables from the database. I've created edmx file with only the tables I need. All the data tables will b...

IQueryable Entity Framework Foreign Key Table Value

Hello, I am having an issue with querying the entity framework (.net 4.0). I have the following: public IQueryable<Comment> GetComments(string section, int sectionId) { var query = from comm in ObjectContext.Comments.Where(id => id.SectionId == sectionId && id.CommentSection == section) select comm; return query; } N...

WCF with Entity Framework Error Part II

Newbie, please bear with me as I just started yesterday with WCF. I am using Northwind for the data and only added Customers, Orders, Order Details and Products to the model, so nothing fancy. When I launch the application and invoke Test, and set a breakpoint, the value for products is there and it completes without error. If I then t...