entity-framework

Performing Insert OR Update (upsert) on sql server compact edition

I have c# project that is using sqlserver compact edition and entity framework for data access. I have the need to insert or update a large amount of rows, 5000+ or more to the db, so if the key exists update the record if not insert it. I can not find a way to do this with compact edition and EF with out horrible performance, ie takin...

Change Entity State

Hello Everyone, I currently have an entity model with a bunch of deleted items, the state is deleted. Is there a way to "undelete" them? I know which Items I want to undelete, but I don't know how to undelete the items. Ideally I'd like to get it back to an unchanged state. ...

ADO.NET Entity Framework and NHibernate - when to use one over the other

I am working in a Microsoft .NET shop where it is okay to use NHibernate or ADO.NET EF. What guidance should we be using about when you should choose one over the other? For example, it seems like when writing a Silverlight app the EF -to-> ADO.NET Data Services -to-> Silverlight would offer a productivity boost, and provide you with a ...

Entity Framework: Ignore Columns

I have a database that I wish to build an EF model from, however I do not want to include certain columns from the database as the columns concerned are maintained exclusively on the server and should not be manipulated by any application. Both of the columns are DateTime (if this makes any difference), one of the columns is nullable an...

Client-Side entity creation with related code tables

I’m on the learning curve up the Silverlight trail. I’m a data-centric developer so I naturally picked up the ADO.NET Data Services client along the way. I’m scratching my head over a real-world scenario and can’t seem to find any help in documentation, blogs etc. I’ve got a complex Tutor entity with related entity sets for Addresses,...

Adding new row with referenced types in Entity Framework (C#)

Hello, i'm working with Entity Framework only few weeks. It's great, but how should i add corectly new row with referenced sub-items (tables)? i tried this procedure CMS.ShopOrder order = new CMS.ShopOrder(); order.CreatedOn = DateTime.Now; foreach (var item in CMS.CurrentSession.Cart.Items) { order.ShopOrderItems.Add(item);...

Entity Framework - Using GUID as condition

Hi, How can I use this sample Inheritance and Associations with Entity Framework but using a data type GUID as Condition? In this sample, I only use Strings and Integers as Condition. Thanks ...

Can MS SQL Views have primary and foriegn keys?

Is it possible to define primary and foreign keys for database Views in Microsoft SQL Server Management Studio? How? I'm trying to create an ADO.NET Entity Data Model to read from four old, poorly-formed database tables that I cannot modify. I've created Views of just the data I need. The four Views should map to a simple three-entit...

Linq to SQL, Entity Framework, Repository Pattern, and Dependency Injection

Hello: Stephan Walters video on MVC and Models is a very good and light discussion of the various topics listed in this questions title. The one question listed in the notes unanswered was: If you create an Interface / Repository pattern for Linq2SQL, does Linq2SQLs classes still cause a dependency on Linq, even though you pass the cl...

Ado.Net Entity : Object doesn't display linked members (foreign keys)

I have a simple databasescheme: User, Account. User has 1-to-many relationship with Account. I have generated a ado.net entity data model, and I can create users and accounts, and even link them together. In the database the account.user_id is correctly filled, so theoretically I should be able to acces User.Account.ToList() in C# throu...

Using an (Sql Server) xml column with Entity Framework

Has anyone tried to use xml typed columns with Entity Framework ? The entity returns a string. Will the next version of Entity Framework support XElement types when the table column is of type XML. Regards. ...

Field max length in Entity framwork

I need to put a max length on my test field on my Views using ASP.NET MVC with the Entity Framework and I can't find how to get the max length of a varchar field. Is there an easy way to get that, or any other property of a database field thanks ...

ORM - Saving/Restoring default values for a DB object with C#

In order to assist users with repetitve data entry, I am trying to implement a system where many of the previous properties are remembered when adding new data. Is it possible to use the Properties.Settings.Default.MySetting functionality or is there a better method for doing this kind of thing? ...

Entity Sql for a Many to Many relationship

Consider two tables Bill and Product with a many to many relationship. How do you get all the bills for a particular product using Entity Sql? ...

Table Inheritance and associations to other tables

Hello, I am very new to Entity Framework and am wondering about the basic concept of Table Per Type Inheritance and how the entity relates to other tables. In the physical database the relation works like the following... Person (Person ID PK) Customer (Customer ID PK, Person ID FK) Order (Order ID PK, Customer ID) My question is bef...

How do I search the collection of a collection in my LINQ Where clause?

I've got the following ADO.NET Entity Framework Entity Data Model: I want to find all the Policyholders with both a Service of a given Id and also a Keyword of a given Status. This LINQ Does Not Work: Dim ServicesId As Integer = ... Dim KeywordStatus As Integer = ... Dim FoundPolicyholders = From p As Policyholder In db.Policyholde...

ADO.NET Entity Framework, Northwind, and Employee.Orders > 0

So I'm trying to work on a sample app. Trying to dig into ADO.NET Entity Framework. I get an employee back using a method with LINQ like this: public IList<Employee> FindByLastName(string lastName) { IList<Employee> emps; var e = from emp in _ctx.Employees where emp.LastName == lastName select emp; em...

Entity Framework - Default Child Objects

Is there a way to set default child entities for a new entity without having to query all of them using ObjectQueries? ...

How to get next sequence number in DB2 using Entity Framework?

I want to retrieve the next sequence number via an adhoc query in Entity Framework. I'm using: LogEntities db = new LogEntities(); ObjectQuery<Int64> seq = db.CreateQuery<Int64>("SELECT AUDITLOG.EVENTID_SEQ.NEXTVAL from sysibm.sysdummy1"); This returns the following error: ErrorDescription = "'sysibm.sysdummy1' could not be resolved...

How to delete many-to-many relationship in Entity Framework without loading all of the data

Does anyone know how to delete many-to-many relationship in ADO.NET Entity Framework without having to load all of the data? In my case I have an entity Topic that has a property Subscriptions and I need to remove a single subscription. The code myTopic.Subscriptions.Remove(...) works but I need to load all subscriptions first (e.g. myTo...