entity-framework

Include in enity framework 4

Hello I've been using enity framework that came with 3.5sp. And now I've redone things for enityframework 4 and asp.net mvc 2. I've come across something (which worked in my previous version and asp.net mvc 1.0). I have this: public IQueryable<Booking> GetBookings() { return from b in _entities.Bookings.Include("BookingObject") ...

insert with many to many relationship

hi, i have 2 object: user, group that have a relationship many to many i want create a user and associate some groups to it. How can i do it? thanks I've tried with this. but it's wrong: user = new User(); List<int> gruppi = new List<int>() {1,2}; utente.Group =db.Group.Where(p => gruppi.Contains(p.GruppoID) ...

array contains in where

hi, i've to get rows from a table CBR_MissioniGruppi that have id in gruppi list. I've tried with this, but doesn't work. List<int> gruppi = new List<int>() { 1, 2 }; foreach (CBR_MissioniGruppi mg in db.CBR_MissioniGruppi.Where(p => gruppi.Contains(p.GruppoID))) How can i do it? thanks ...

code only in entity framework

hi there i have the final version of visual studio 2010 i wanna use CODE ONLY in entity framework i wanna know what is ctp what is ctp in entity framework please help me ...

Entity Framework 4 executes stored procedures for insert operation in incorrect order when there is multilevel parent child relationship

Hi, We are encountering a strange problem with Entity Framework 4. Our model contains an entity which is associated with 3 entities, let us call them first level children. One of the child entity is associated to another entity - let's call this as second level child. All these 5 entities are mapped to stored procedures for performing ...

Unique value in table using EF4 and locking

In this code, I have an Entity Framework 4 model with a single "Thing" entity that has an Id and a Name(string) column. I would like to ensure that when I call FindOrCreateThing(name) from multiple threads, only one row in the Things table will ever be created with the given name. Currently, I'm using locks to accomplish this, and it se...

Disable Foreign Key Exposure in Entity Framework?

When I originally created a Dynamic Data project I told it to expose the foreign keys, but now I can't make mappings between two entities b/c of the foreign keys. When I click on mapping details while focused on my association I receive the message: Mappings are not allow for an association over exposed foreign keys. So I'd like to...

There is no property with name 'restriction_class_id' defined in type referred by Role 'phones_extensions'

I created a new Entity Framework model from a database. This database has a number of tables, the main table is phones_extensions. The phones_extensions table has columns which are FK's to the other tables - e.g. the restriction_class_id is an FK linking to the phones_restictions_class table where the PK is ID. The EF4 model automatical...

How do I generate Entity Framework 4.0 classes from the command line that have different names than my schema objects?

I want to generate Entity Framework 4.0 classes from a (legacy) database from a command line, but I have 2 transformations I want: Tables/columns are lowerCamelCase and I want my classes/members to be UpperCamelCase. I want to suffix my classes with "Dto". Any idea how this might be accomplished? I'm a total newbie to EF, but I have...

Entity Framework newbie question

I'm having trouble understanding EntityFramework I have a table called "Categories", with columns "IdCategory,CategoryName". I have a table called "Country", with columns "IdCountry,CountryName" I have a table called "Product" with Columns "IdProduct, IdCategory,IdCountry,ProductName" When I create de EDM it maps all 3 entities. Produ...

Avoid getting data from entity framework's cache

Hi all, I have a weired problem. One of the pages in my application show's status of tasks in a table. I am using entity framework ( entity to object) to do all the data handling with DB. I noticed that even though the status is updated in DB, its not reflected on my webpage even after continuous refresh! If i stop the server and start ...

Does the EntityDataSource support "it.Property.Property" syntax?

I have an EntityDataSource where I'm trying to replace some previous code-behind work. My EntityDataSource looks like: <asp:EntityDataSource runat="server" ID="personDataSource" ContextTypeName="Model.GuidesEntities" EntitySetName="CharacterFavorites" OrderBy="it.Person.FullName" ...

EFv1 mapping 1 to many Relationship to POCOs

I'm trying to work through a problem where I'm mapping EF Entities to POCO which serve as DTO. I have two tables within my database, say Products and Categories. A Product belongs to one category and one category may contain many Products. My EF entities are named efProduct and efCategory. Within each entity there is the proper Navigat...

IEnumerator seems to be effecting all objects, and not one at a time

Hey, I am trying to alter an attribute of an object. I am setting it to the value of that same attribute stored on another table. There is a one to many relationship between the two. The product end is the one and the versions is the many. Right now, both these methods that I have tried have set all the products returned equal to the fin...

Can I have Entity Framework and Linq-to-SQL run together?

I'd like to know if it's possible to have both Linq-to-SQL and Entity Framework running side-by-side. Our current configuration is Linq-to-SQL and we'd like to eventually move to EF. But there's just too much going on in the Linq-to-SQL side right now and we'd like to do it in phases. so any chance we can just start writing new stuff i...

Complex orderby question (entity framework)

Ok, so I will start by saying that I am new to all this stuff, and doing my best to work on this project. I have an employee object, that contains a supervisor field. When someone enters a search on my page, a datagrid displays employees whose name match the search. But, I need it to display all employees that report to them and a third ...

Creating DataAdapters for Entity Framework

This relates to the reporting suite we are using, but I believe the pattern is the same for WinForms and other .NET technologies. The reporting suite we are using (XtraReports 10) supports design time preview of the data if the DataAdapter property is set. When using a DataSet datasource, a TableAdapter is generated (by the DataSet), wh...

Autonumber with Entity Framework

I want to loop through a collection of objects and add them all to a table. The destination table has an auto-increment field. If I add a single object there is no problem. If I add two objects both with the primary key of zero, the entity framework fails. I can manually specify primary keys but the whole point of trying the EF was t...

Entity Framework: a proxy collection for displaying a subset of data

Imagine I have an entity called Product and a repository for it: public class Product { public int Id { get; set; } public bool IsHidden { get; set; } } public class ProductRepository { public ObservableCollection<Product> AllProducts { get; set; } public ObservableCollection<Product> HiddenProducts { get; set; } } Al...

Using entity framework to connect to multiple similar tables in .net MVC.

A relative newcomer to .net MVC2 and the entity framework, I am working on a project which requires a single web application, (C# .net 4), to connect to multiple different databases depending on the route of access, (ie subdomain). No problem with this in principle and all the logic is written to transform the subdomain into an entity c...