entity-framework-4

Entity framework 4 and sql filestream to read a file from db

Hi there, I'm using ASP.NET 4, EF 4 and FILESTREAM in SQL 2008 to add/read files to the DB. I'm able to upload files just fine, but I'm not able to retrieve the files the way I want to. Here's what I'm doing - I have a grid which displays a list of files. Each line item is a file with a CommandName and CommandArgument set. The user c...

Update non-scalar entities in Entity Framework v4

Currently I am updating the scalar properties of the candidate object like so: public Candidate EditCandidate(Candidate candidateToEdit) { _entities.Candidates.Attach(new Candidate { ID = candidateToEdit.ID }); _entities.Candidates.ApplyCurrentValues(candidateToEdit); //update candidate.contact h...

Constructor error in WCF service implemented with Repository and UnitofWork patterns.

I have a WCF service which implemented using Repository and UnitofWork patterns. And now I am getting following error: The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to t...

Generated Entity Framework Code

The code that gets generated by Entity Framework 4--mainly the AddTo and Create methods--should I be using those directly? I'm trying to understand the Create method. The CreateDinner method (in NerdDinner) for example is this: public static Dinner CreateDinner(global::System.Int32 dinnerID, global::System.String title, global::System...

Entity state always unchanged if relation is multiplicity on both ends?

Hello world! I have the multiplicity relation on both ends in object graph. Let say I have Projects<---->Users. The issue is that when adding user to project project.Users.Add(user) or reverse none of the entities(project, user) gets marked as modified. The ObjectContext.Commit return 1 change happened. The question is whether it's...

Complete examples using MVC2, EF4, and Repository Pattern with true SoC

I'm having trouble finding examples of ASP.NET MVC solutions that use EF4 in their repository while adhering to SoC. Can anyone provide me with references to examples (open source, books, tutorials, articles, etc.) that demonstrate the following? ASP.NET MVC 2 Entity Frameworks 4 Repository Pattern Separation of Concerns (i.e. BL does...

Nerd Dinner - how is the return type of the EF queries determined?

In Nerd Dinner's Entity Framework repository, the queries' return type corresponds to the model and not to the EF conceptual entity. public IQueryable<Dinner> FindAllDinners() { return db.Dinners; } ... public ObjectSet<Dinner> Dinners // NerdDinner.Designer.cs, line 76 The type of Dinner is NerdDinner.Models.Dinner. I noticed ...

EF: Lazy loading, eager loading, and "enumerating the enumerable"

I find I'm confused about lazy loading, etc. First, are these two statements equivalent: (1) Lazy loading: _flaggedDates = context.FlaggedDates.Include("scheduledSchools") .Include ("interviews").Include("partialDayAvailableBlocks") .Include("visit").Include("events"); (2) Eager loading: _flaggedDates = context.FlaggedDates; In oth...

Attach additional ObjectSets to ObjectContext from separate project

Hi, I hope this makes sense. I have a ASP.NET web application that uses Entity Framework. I have added a couple of custom tables to the db and created a separate project to handle the CRUD operations for those tables. I chose the separate project because I don't want future upgrades to the application to overwrite my custom features. ...

Asp.net mvc with entity framework problem : creating or updating an address for a contact . Address Fill with Ajax Request.

I have 2 related entities: Contact and Address. There is a relation between each other. 1 Contact with 1 Address. In the create Form, I fill the FirstName and LastName text boxes. I have a field related to the address. In some situations, I perform an AJAX request to fill automatically the Address Info. The problem is: when I click s...

When can i use EF4's 'Include FK Columns in the Model' ?

Hi, i'm a little confused about EF4, and the EF homepage doesn't help me, so... First thing: is EF4 a separate download or is it a part of VS2010? What version of EF is native in VS2010. Reason why i ask is because i create a .Net 3.5 project in VS2010 (.Net 4.0 is not yet on the production server) and when i want to check the checkb...

Left Outer Join LINQ To Entities

I have the following entities: Clients -- ClientID -- ClientName Contractor -- ContractorID -- ContractorName PreferredContractors -- PreferredContractorID -- ClientID -- ContractorID So I have a list of clients and contractors. The clients prefer to work with certain contractors than the others. I want to build a LINQ to Ent...

Entity Framework testing with IRepository - problem with lazy loading

I am refactoring an MVC project to make it testable. Currently the Controller uses the Entity Framework's context objects directly to ask for the required data. I started abstract this and it just doesn't work. Eventually I have an IService and an IRepository abstraction, but to describe the problem let's just look at the IRepository. Ma...

How to map EF4 Complex Type as seperate/dedicated table in Database.

Is it possible to use EF4 ComplexType as Table (similar to EAV style)? From the designer, I define ComplexType X as part of Entity A. In Database, I would like to have Table A and X, where table A has a foreign key to Table X. ...

RIA Services: Server process returns multiple entities but Client shows 1 entity duplicated

I am running into an issue where RIA Services returns 3 entities from the server (I have verified while debugging on the server process, and have verified via Fiddler that the service is in face returning 3 entities. I am using MVVM so I am calling Load on the client side using a helper function that I borrowed from a Shawn Wildermuth ...

Entity Framework 4, free Oracle provider?

Can i user ODAC or another free provider in EF4? ...

Is there a way to default the namespace in RC version of STE's with an EDMX?

I have a project utilizing EF4 and Self Tracking Entities (STE). In the pre-release version of STE's you could add the "Namespace" value to each EDMX different from the default Namespace of the current project. (Open EDMX, right click: Properties, Set the "Namespace" attribute.) When you set this in the pre-release version and use the...

Does EF4 support mapping 1 component from several tables?

At my company we have a database with one table being so big that it was splitted into 3 tables. They all share an ID and the info is NOT normalized so there is info for several entities in the tables, some entities actually have some fields in one table and some fields in the other tables. There is a new project and they want to use nH...

Generating Integer Identity Primary Key for Entity Object in Entity Framework and SQL Server CE

Hello I heard that this issue is fixed in SQL Server Compact Edition 4.0 CTP As recently I just stepped into SQL Server CE and Entity Framework, and VS2010 not yet supporting SQL Server CE 4.0 I think I would need a work around for this issue Can I know how to generate an Integer type Identity Primary Key inside the constructor of th...

How should I name database wrapper object?

For my CMS application I'm writing a DLL that I will include into my projects. That DLL will include funtionality like retrieving all news for a specific project. For instance, my database contains a table called News. By using the Entity Framework 4 I have a automatic generated class called News. I do not want my DLL methods return thi...