entity-framework

Leaky abstraction in LINQ to SQL EntitySet

Hi, I’m having trouble with some dbml generated classes that don’t to resolve down to efficient SQL. Imagine I have an Accounts table and a Transactions table where each transaction is associated with a particular account. I load all this into dbml and out pops an Account class and a Transaction class. The Account class has an Entity...

Associating to static data using Entity Framework

Having a bit of a mental block about how this should work: I have two tables Location and Country. Within the Location table I have a FK to the Country table PK which is CountryCode. The Country table is filled with static data and each time I add a new location I will link to the Country with the appropriate countryCode. I can do ...

MSDTC with Entity Framework

I have an app that is saving to a db (using Entity Framework) and saving documents to Sharepoint in a single save. I'm attempting to use MSDTC with a TransactionScope. Part of my EF insert logic includes passing a list of foreign keys to the data layer. The layer retrieves the "foreign key'd" object from the db and then adds it to t...

Entity Framework : Merge Entities into Navigation Property

Given these Entities auto generated by EF...(pseudo) class CreditCard { int ID {get;set;} string Number {get;set;} } class Person { EntityCollection<CreditCard> CreditCards {get; set;} } What is the best way to merge a disconnected List into the CreditCards property of Person. A List will be constructed on a WebForm based...

What are the Costs of Running a Busy site like Stackoverflow with SQL Server

My site is small now but it is steadily getting popular online. It is running SQL Server express and entity framework. I am not storing any pictures in the database, the database is storing just text. What kind of costs would I be looking at if my site gets big enough where I need to upgrade my database to a paid version and run the data...

Creating a custom property in Entity Framework

I have a database I'd like to create an entity from, and then generate RESTful output. My objective is to add a property to one of the tables once it becomes an entity. The data for that property would be one I'd come up with through calculations done on a few different fields in the table. From there, the code generator would create ...

How to restrict the entity set for a navigation property.

I have just merged several identical legacy tables, DeptL1, deptL2, ..., deptL*n*, where L is a reporting roll-up level, into one table, Dept, with a new ReportingLevel field. In my previous model, several entities, e.g. Employee, had an 'FK' relationship only with DeptL1, where they now have an 'FK' relationship with the whole Dept tab...

ADO.NET EF and LINQ pagging records & translation to SQL

Hi there I saw a ADO.NET EF and LINQ pagging structure like this: var query = ...your normal query here... int totalRecordCount = query.Count(); var pagedQuery = query.Skip(PageIndex*PageSize).Take(PageSize); This code seems to query all records setting them into the local memory, so it gets the total count. After that, it pages de r...

MS-SQL Filling in Identity column values

I'm building an ASP.Net/MVC application using SQL 2008 Developer edition and a DB in Sql2005 compatibility mode. Using Entity Framework as DAL. My problem is that I have a table where I'm using the integer identity column in a like an Invoice Number, that is, it always has to be unique and never reused. So using the GUID column type w...

Linq to Entities and SQL Server 2008 hierarchy id

Does Visual Studio 2008 SP1 / .NET 3.5 support Linq to Entities (ADO.NET Entity Data Model / edmx) with SQL Server 2008 R2? Specifically, the hierarchy id type? If so, do you have a download link, if not is there a published date when this feature will become available? I experimented a bit today after installing GDR R2 to support Sql...

Entity Framework - New entities with new children cannot be added with savechanges

I am creating an object called "letter" which has multiple "recipients" added to it. when savechages is called on the context i get this error. "Entities in 'EchoEntities.LetterRecipients' participate in the 'FK_LetterRecipient_Letter' relationship. 0 related 'Letter' were found. 1 'Letter' is expected." Also when only adding 1 recipie...

Where can I find the .NET Framework 3.5 Entity Framework Sample application files that are described in the MSDN documentation?

Where can I find the .NET Framework 3.5 Entity Framework Sample application files that are described in the MSDN documentation? The download link in the MSDN documenation is a link to the Visual Studio 2008 SP1 download. ...

Designing DATA Access Layer in ASP.NET 3.5 app

I need to decide about the DATA Access Layer of a medium sized web application to be run on the intranet of a company. I've worked with CodeSmith before and found it useful but it consumes lot of development time if the underlying database schema changes, so would like to do away with it and try my hands with some new DAL which would hel...

Entity Framework and repository pattern problem.

Hi! I am using generic repository pattern with methods: private ObjectQuery<T> ObjectQueryList() { var list = CamelTrapEntities.CreateQuery<T>(EntitySetName); return list; } public IQueryable<T> List() { return ObjectQueryList(); } Metod List() returns IQueryable<T>, becase IQ...

Entity Framework V4: "Code Only" performance considerations

I'm about to start working on a new project and am wondering if "Code Only" is the right way to go. We're also considering the other model-first approach through the designer, but would rather design my domain models outside of the EF designer. Our domain will likely contain 100+ entities. I've read that a huge number of entities can ...

Rules of thumbs for writing "queries" using ADO.NET Entity Framework

I’m currently working on a prototype of a medium size web application, and I thought that it would be good to also experiment with Entity Framework. The problem is that the major part of the application is not the data layer and logic, and so that I don't have much time to play with Entity Framework. On the other hand, the database schem...

C# Silverlight with Entity Framework - Change Return Type On AutoGenerated EntityQuery!?

Background Currently I have a C# Silverlight business application which uses RIA Services. The application is hosted in ASP.NET using the ADO.NET Entity Framework and a domain service class to read and write to the SQL Server database. Scenario I have a server-side method in my DomainServiceClass that returns an IEnumerable list of ob...

ADO.NET Framework change tracking

Hi, i just wanted to ask if there is a way the reject all changes made to a ADO.NET Framework model with its relations? Auditing in Entity Framework describes a way the restore the original value of a single entity. But is this possible for all unsaved changes in the whole database? ...

"Read-Only" Entity Framework? I'm trying to use RIA Services, EF, and Silverlight

I'm trying to present MySQL server data in a silverlight client and my current plan of attack is to use Entity Framework to MySQL with RIA Services providing the data access between the Silverlight Client and Entity Framework. However, I'm only trying to present data to the user and I do not want the possibility of me or someone else be...

change db name in connection string at runtime in Entity Framework

Hello guys, In my project I want to run some unit tests on the DAL layer that is using EntityFramework. I'm creating from scrips a new database before each run of the tests (in order to have always the same initial data when doing the tests). At the end of the tests, this database is dropped, (all is made automatically with the help of ...