entity-framework

Entity Framework - Mapping doesn't map for stored procedure?

I have a stored procedure that search a view using full text. I'm trying to map the results to an existing Entity (Sales), where I mapped the column MivType to SaleType (as it makes more sense, and I want to keep db names away from my web site). The stored procedure is mapped to a Function Import, and I've defined its ReturnType to Sales...

linq to entities qustion

Hi Experts, I am working on a project for automobiles listing. I am using linq to entities. I have a table listing and corresponding a class Listing in my data model. Listing { Listingid, AccountID, MakeId, ModelId } I have lookup table where I keep all the lookup values for makes and models. Lookupvalues { id, Description } I...

EF4 POCO one to many Navigation property is null

I'm using VS2010, EF4 feature CTP (latest release), and POCO objects, such as the example below: class Person { public int ID { get; set; } public string Name { get; set; } public virtual IList<Account> Accounts { get; set; } ... } class Account { public string Number { get; set; } public int ID { get; set; } ... } For the sak...

Using Reflection to Remove Entity from RIA Services EntityCollection?

To facilitate control reuse we created a solution with three separate projects: a control library, Silverlight client, and ASP.NET backend. The control library has no reference to the RIA Services-generated data model classes so when it needs to interact with it, we use reflection. This has worked fine so far but I've hit a bump. I ha...

DataContractSerializer leaking memory untill process die

Hi guys! I have a .net4 application using EF4, I Expose my model through WCF using BasicHttpBinding (but this can be changed) that every time I try invoke this method my web server process start to grow in memory and the process die. The problem is when the DataContractSeralizer trying to serialize my Entity (has some relationships) ...

VIEWs in Entity-Framework?

Hello! I have a table called Item. I have a view called ItemView, that returns all the column of Item + one more aggregated column, that I want to be read only. I need to use it in Entity Framework, and I don't know how I should use it, since when insert the view in the designer, all the fields become entity-keys, besides no relations...

How To Count Associated Entities Without Fetching Them In Entity Framework

Hello everyone, I've been wondering about this one for a while now, so I thought it would be worth using my first Stack Overflow post to ask about it. Imagine I have a discussion with an associated list of messages: DiscussionCategory discussionCategory = _repository.GetDiscussionCategory(id); discussionCategory.Discussions is a lis...

Loading partial entities with Linq to Entities

I am trying to load a partial entity with Linq to Entities: Dim contacts = From c In My.Context.Contacts _ Select New Contact With { _ .ContactId = c.ContactId, _ .Name = c.Name } I tried it and I get the following NotSupportedException: "The entity or complex type 'CompleteKitchenModel.Contact' cannot be c...

who does the validation in basic asp.net mvc + entity framework program

I have a very simple ASP.NET MVC application with Entity Framework-based model. Essentially, just a Product table from AdventureWorks database. Controller only has Index and CrUD methods. Create has the following: if (!ModelState.IsValid) { return View(); } // Save to the database Some of the field...

C# Convert (not cast) inherited object to new base object

Hi, i have an UI object VehicleUI which is inherited from Vehicle. It's the same, but it has some extra propertys for the user entry process. Now i want to save the VehicleUI to the database in the table Vehicle (using the entityframework). In my opinion this must be possbile because the VehicleUI has all the properties of the Vehic...

How can I map database table and field names back into their EF Entity object and property names?

I have a database table which records all field changes in all database tables which are mapped to Entity Framework Entities (via SQL Server triggers). I am building a service which outputs these field changes to the client. However, the client needs the EF-Entity object and property names and not the database table and field names. F...

Is it possible to combine the Sync Framework with the Entity Framework?

Before I start (re)designing my app, I would like to know beforehand: is it possible to compbine the sync framework with the Entity Framework? We are planning to use SQL Server only (for now). Are there any known issues? Thanks for your reply. Bart ...

How to refresh the DataSource on a WinForms DataGridView?

I populate the GridView.DataSource from a EntityFramework Model: gwTimeLog.DataSource = _entities.TimeLogs; When a new row is added to the _entities, I try to update the grid (tried using the same statement as above, setting it null, then back to _entities.TimeLogs, etc...), but the grid simply won't update. Even though _entities.Tim...

Retrieving a tree structure from a database using LINQ

I have an organization chart tree structure stored in a database. Is is something like ID (int); Name (String); ParentID (int) In C# it is represented by a class like class Employee { int ID, string Name, IList < Employee> Subs } I am wondering how is the best way to retrieve these values from the database to fill up the C# Obje...

EntityFramework v4 ApplyCurrentValues not saving referenced property changes

I have a project where I am using EFv4 to save data back to my repository. This is working as expected for the simple properties on my object but does nothing for the related objects. For example, I have a User object and a related property Roles that is a collection of Role entities. If I update the User's lastActivity date and the...

Using an Interface with a navigation property

I am trying to setup a project using Entity Framework 4, POCO, and Code-Only. Is it possible in entity framework for type of a navigation property to be an interface? I have a "Task" class. A Task can be assigned to a user or a group each of which are represented by a separate class and stored in separate tables. The classes look som...

Why is this referenced entity object null?

I have a strongly-typed view that receives a Design model for its rendering. My Design class (Entity) has a many-to-one relationship to a Designer (i.e. 1 Designer can have 1 or more Designs). When trying to use the following code, I get an NullReferenceException for the Design.Designer relationship. Obviously I'm doing something wron...

Problem with double one-to-many in EntityFramework

I have model KlientTrasa which has reference to objects Klienci and Trasy. I'm trying to delete all references and then add new ones in this way: // delete all foreach(var kt in trasa.KlientTrasa.ToList()) { //_entities.DeleteObject(kt); trasa.KlientTrasa.Remove(kt); } //...

Custom validator not invoked when using Validation Application Block through configuration

I have set up a ruleset in my configuration file which has two validators, one of which is a built-in NotNullValidator, the other of which is a custom validator. The problem is that I see the NotNullValidator hit, but not my custom validator. The custom validator is being used to validate an Entity Framework entity object. I have used...

EntityFramework, RIA insert problem - Updating child objects causes an Insert

I've got a database which has a table called m_AttentionFlags which references a primary key in m_PermissionCollections. I've built an EntityFramework model from this and created a DomainService. Now using RIA on the client I have loaded the flags into the local context on initialization of a control: var query = _context.GetM_Attenti...