entity-framework

DataContractSerializer: How to serialize classes/members without DataContract/DataMember attributes

DataContractSerializer requires classes and members to be marked with the DataContract and DataMember attributes. However, in my case the classes are auto-generated with the EFPocoAdapater framework and these attributes are not present. How can I force serialization of all members using the DataContractSerializer without these attribut...

Request for AspNetHostingPermission failed on EDM Load

I am using Entity Framework in an application i am working on, however when i try to launch it from another user's machine, while trying to load the EDM i get an Exception stating that the request for the AspNetHostingPermission has failed. The assemblies are located on a network share. The assemblies are not signed and as far as i know...

How does a Silverlight client access Azure stored data?

I am thinking of developing a Silverlight application and want to make use of Windows Azure for the data storage (as well as scalability etc). But I am not sure how to get data to and from Azure using Silverlight. What technologies should I be investigating? What is the recommended approach for this scenario? Should I be looking at usin...

Entity Framework and coupling

Hi, I had a little discussion with a friend of mine about the use of Entity framework. I had a project where I made a 3 tier solution with the entity framework as my datalayer, and used Data Transfer Objects to move from the business tier to user interface. I really liked the loose coupling it gives, since I can change the entity framew...

Can I lazy load scalar properties with the ADO.Net Entity Framework?

I've got a database table Image with one huge column: Data. I'd rather lazy load that one column so I'm not querying all that when I get a list of all my images. I know I can put the data into its own column and entity like this: But, do I have to? ...

Converting a LinqToSql DAL to EntityFramework

I've got an app that is just over 1yr old but it still evolving and will likely revolve more and more around a growing database schema in the near to mid term. The app was written using LinqToSql which has met our needs fairly well. We have run into a few pain points but have worked around them. I would currently consider this app to hav...

Linq and a select with two tables

Hi! I want to make this select using linq: Select cd.name from Content c, ContentDetail cd where c.id_contentTypeID = contentTypeId and c.id_contentID = contentID and cd.id_contentID = c.contentID; I have done the following but I don't know how to end the query: var list = from c in guideContext.Content, dc ...

Microsoft Entity Framework

I'm not sure if this question is appropriate for SO, but I'm sure a few people here have been through it: I'm trying to follow the MVC tutorials on the ASP.NET website and there's a point at which it has you add an ADO.NET entity to the project, but for some reason, it doesn't appear on the dialog for adding a new item. I've got SP1 for...

Cannot execute stored procedure with ADO.NET Entity Framework

I've created a simple parameterless stored procedure which I've pasted below. I've imported the stored procedure to my Entity Model and created a Function Import. The function in the model is never created and I am unable to execute this stored procedure using the ADO.NET Entity Framework. I've opened the .edmx file in XML view and have ...

How do you retrieve records and all child records in one database hit in ADO.NET Entities?

Hi there, I would like to make one database call to retrieve the following data, but I'm struggling to figure out what the LINQ should look like. Here's my current implementation (I know it's bad!!): var photos = from photo in entitiesContext.Photo join pg in entitiesContext.PhotoGallery on photo.PhotoGallery.PhotoGalleryI...

Entity Framework - Linq To Entities - Many-To-Many Query Problems

Hi, I am having problems querying many-to-many relationships in Linq To Entities. I am basically trying to replicate this query using Linq: Select * FROM Customer LEFT JOIN CustomerInterest ON Customer.CustomerID = CustomerInterest.CustomerID LEFT JOIN Interest ON CustomerInterest.InterestID = Interest.InterestID WHERE Interest.Intere...

Linq-to-entities - Include() method not loading

Hi If I use a join, the Include() method is no longer working, eg: from e in dc.Entities.Include("Properties") join i in dc.Items on e.ID equals i.Member.ID where (i.Collection.ID == collectionID) select e e.Properties is not loaded Without the join, the Include() works Lee ...

Entity Framework: Regeneration of changed tables (key changes)

I've got a pretty large DB hooked up to my Entity Framework. I've got one particular set of tables where a common key (fk) was deleted from the design. When I "update the model from the database", I get a series of errors about this now-missing key. Why doesn't the update process accurately detect that this key was removed? Also, if I m...

Why doesn't TransactionScope work with Entity Framework?

See the code below. If I initialize more than one entity context, then I get the following exception on the 2nd set of code only. If I comment out the second set it works. {"The underlying provider failed on Open."} Inner: {"Communication with the underlying transaction manager has failed."} Inner: {"Error HRESULT E_FAIL has been re...

Can I update an EF Entity without querying for it first?

Here's my scenario: I have a simple message that is passed in via WCF. this message represents an existing database record and has all of the datafields required to do my calculation. Once I'm done with my calculation, I want to update one field on this datarecord. Currently, attempting to simply set all of the fields of the Entity ...

Quickest way to learn Linq to Entities

I am developing my first ASP.NET MVC application using the Entity Framework. I have no previous .NET experience, although I'm fluent in other OO languages. I am having trouble understanding Linq to Entity query expressions, more specifically its syntax and how to render the results on an ASP page. For example, I am joining three tab...

EntityFramework ObjectQuery<T>.Include With Filter ability

Hi, I'm using ObjectQuery.CreateQuery() to create eSQL query. I want to use the ObjcetQuery.Include to load related data, like Customer => Orders so let the EF to load all the orders for customer at the same time. The issue is that i don't want all the related objects and i want to fetch the result with condition. Any idea? ...

Problem when using Entity Framework in ASP.NET MVC

I use Entities Framework to implement my data accsee layer in ASP.NET MVC. I got a problem in View. When my code in the VIEW something like: <%= Model.FirstName %> I got an error in run time: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web re...

LINQ to Entity: using Contains in the "select" portion throws unexpected error

I've got a LINQ query going against an Entity Framework object. Here's a summary of the query: //a list of my allies List<int> allianceMembers = new List<int>() { 1,5,10 }; //query for fleets in my area, including any allies (and mark them as such) var fleets = from af in FleetSource select new Fleet { ...

Changing Entities in the EntityFramework

Hi! I have the following scenario: Entities are loaded from the database. One of them is presented to the user in a Form (a WPF UserControl) where the user can edit properties of that entity. The user can decide to apply the changes to the entity or to cancel the editing. How would I implement something like this with the EntityFram...