entity-framework

SQLite with Entity Framework

I'm having a problem with primary keys in Entity Framework when using SQLite. SQLite wants an explicit NULL in the VALUES list on an autoincrementing primary key column. I haven't actually looked at the generated SQL in the EF Context, but I believe it's going with the usual SQL Server convention of providing no value for the autoincre...

Delete an object and all of it's related entities in Entity Framework

Hi, Does anyone know how to delete an object and all of it's related entities inside of EF without manually traversing the object graph and deleting each one? For example, I've got SalesOrder and SalesOrderDetails with a 1:N relationship between them. When I delete a SalesOrder, I want all SalesOrderDetails to be deleted automatically....

Linq2SQL for a new project

EDIT Appreciate all the inputs guys. Opinions were very welcome, I think we'll go with an L2S implementation at this point and just roll-up/encapsulate our DAL in such a way that if we need to change to EF in the future, it won't be too painless an operation. As it was pretty subjective, points go to the poster with the most upvotes. ...

How to refresh collection on client?

//It must be tagged by RIA Services also, but I can't find this tag. I loading data on client from server. var context = new WordsDomainContext(); context.LoadWords(); And I using my collection context.Words on client as I need. It's working good. But I want to refresh my context.Words for some reasons. When I call again context.Loa...

Extending Entity Model

Hi: We have a EMD from some SQL Database. Over this Model we create some CLASSES. Now we want extend our project...this implicates adding some new columns in CLIENTE table on the database and extend CLASSES to work with this new columns. Question is there any way to extend the EMD model or we have to build it from scratch an lose the...

Must specify mapping for all key properties in Entity Framework?

I'm trying to set up an Entity Framework model tied to a bunch of views. When I add a view it wants to make most of the fields into an Entity Key for no apparent reason. Worse yet, when I try to create an association between two of these views I get an error saying I must specify mapping for ALL key properties... even though I had cha...

ADO.Net Entity Framework/Linq

I'm look at learning a bit more ASP.Net MVC and Linq To Entity. I'm working on a project using this and am having a problem with the following line of code ViewData["ProjectName"] = db.Projects.FirstOrDefault(p => p.ProjectId == task.ProjectId).ProjectName; It works fine when the record exists but if no record exist it errors becau...

ADO.Net Entity Framework Relationships

I have 2 tables that are mapped in my entity model which are basically this Tasks ( TaskId TaskName Description ProjectId (Foreign Key) ) Projects ( ProjectId ProjectName ) I retrieve my task using Linq to Entities like this Tasks task = (from t in db.Tasks where t.TaskId == id select t).FirstOrDefault(); The tas...

Entity Model does not load

Whenever i try to open my Entity Model, i get a not very helpful error message stating that "the operation could not be completed". So unfortunately i don't have more specific information. However, i have other models that open just fine, and i didn't make any significant changes to the model, other than renaming entities. Are there any...

Entity Framework: Inheritance and Include

Assume the following hierarchy: class Department { EntityCollection<Employee> Employees; } class Employee { string Name; } class RemoteEmployee : Employee { Country Location; EntityReference<Country> CountryReference; } So, department contains a list of employees. There is a hierarchy of employee types, some types reference other e...

Is there a transient type in ADO.NET Entity Framework?

I am using .net 3.5 framework sp1 and VS 2008 sp1. I have created an edmx model. I couldn't create a transient (which is not persisted to the database) property . Any ideas? ...

Opinions on Expression Tree Serialization Library from CodePlex?

did someone tried this code library and have opinion about it? http://code.msdn.microsoft.com/exprserialization 10x ...

Can you Insert/Update using a .NET function or web service when using Entity Framework?

Our ticketing system let's us read the database directly, but updates need to be done either through a web service or an insert to a special "staging" table and then calling a web service to trigger the processing of their business logic. We have a few classes that manage this currently, but I am rewriting everything to use Entity Frame...

Adding a random Guid column to a Linq to Entities query to grab random records

I've found some articles about using the RandomView view and the GetNewID function to pull back randomized records, but they are using this method with Linq to SQL which allows Functions and Stored Procs to be used with no return value or a scalar return value. From what I understand, a Stored Proc has to been returned as one of the Enti...

How can you make an association without using all entity keys in entity framework?

I'm getting more and more frustrated with EF... I have a table called ExtendedField with: Record DocRef DocType Name Record is the primary key DocRef and DocType are foreign keys used to identify which Ticket they belong to Name is the key used by the "definition" table to define what the field actually is So basically I need 2 ...

Store Relational database as XML

I have to store relational data (text, numbers and pictures) into an XML file. I want to maintain the relationship between data and the tables structure. How do I go about doing that? My Windows Mobile application use Windows Communication Foundation (WCF) to get data. Once it gets the data it stores them into an XML file. The WCF use...

Using the same DataContract between Services

Hi, I'm writing a few WCF services that expose data being retrieved from the Entity Framework, and in following Domain Driven Design patterns, I've got a repository per aggregate. The concrete example is a collection of questions and answers. There is a QuestionRepository and an AnswerRepository. I'm running into problems when I want...

Looking for examples of ASP.NET MVC applications with the Entity Framework

Are there any open-source examples of ASP.NET MVC applications that use the Entity Framework? I have found Nerd Dinner to be helpful but it is using Linq to SQL. I am trying to use the Entity Framework in a strongly-typed ASP.NET MVC project and am finding that anything beyond the simple tutorial becomes rather difficult to implement. ...

Adding & Removing Associations - Entity Framework

I'm trying to get to grips with EF this week and I'm going ok so far but I've just hit my first major snag. I have a table of items and a table of categories. Each item can be 'tagged' with many categories so I created a link table. Two columns, one the primary ID of the item, the other the primary ID of the category. I added some data m...

Delayed commit of Entity Framework entities

I'm creating an Asp.net MVC site using the Entity Framework and am wondering how to keep new and updated entities in memory across multiple requests without committing to the database. Say, for example a user goes to a view for editing an entity, and on that view they can add children to the entity. I would like to not commit the change ...