entity-framework

Entity classes created by Entity Framework and LINQ to SQL

HI , The designer creates Entity classes as partial when using LINQ to SQL and the Entity Framework. Is there some way we can create the Entity classes as .cs physical files while using LINQ to SQL or the Entity Framework ...

Performance Degradation after defining multiple relations in Entity Framework (VS 2008 SP1)

Hey Guys, I have a Strange problem, been using EF for quite a time now but never came across such trouble, i have a table which is related to 15 tables. Now the problem is that if i define all the relations my project becomes dead slow, it takes long time to build and run. What could be the trouble? Please enlighten me Thanks ...

Add custom abstract base class between EntityObject and generated classes in Entity Framework

I have generated an EDMX project, and I have my data entity classes set up. They all inherit from System.Data.Object.DataClasses.EntityObject. What I would like to do is have another abstract class that inherits from EntityObject, and then my data entity classes inherit from that new class. What is the best way to accomplish this? Th...

Moving from Entity Framework 3.5 to 4.0

VS.net 2010/.net 4.0 RC was just released. For those who have used Beta or even the RC how easy/difficult is it to upgrade from entity framework 1.0 to 4.0? Some things I'm wondering about: EF1 didn't support foreign keys in the model. I read that EF4 does. I guess if we want to use foreign keys there will be code changes to make? ...

EF4: There is no property with name 'CountryId' defined in type referred by Role 'Customer'.

Within my database (SQL2008), I have a customer table and a country table (among others) and there is a foreign key relationship defined in the database between these tables based upon "Country.Id -> Customer.CountryId". I have created an EF model using VS2010 RC and built this model from the database. When generating the model, I selec...

How to use a custom property in a LINQ-to-Entities query

I have a class Post which is an Entities Framework model. It contains a property like this: public bool Showable { get { return this.Public && this.PublishedDate > DateTime.now } } I can use it in a query like this: from p in db.Posts where p.Showable select p; but when I have a property that uses it, like this public IEnu...

Entity framework: query executing 'select from' for no reason

I'm having some issues with the entity framework. I'm executing a simple select from a view in the database. However, when I view the SQL that EF generates, it is executing the query twice using a select from. Is this the way it is supposed to operate? It seems very inefficient. var reads = (from rt in ctx.C2kReadsToTransfer ...

Entity Framework not sending Where clauses as WHERE clauses to SQL Server

I have a simple DB that has Sites, and each Site has a bunch of Posts. I'm trying to get all the "Public" Posts of a certain Site (I have a variable called site that is already an instance brought by EF) The first obvious thing is: var posts = from post in site.Posts where post.Public == true orderby post...

Using Sculpture with NHibernate or Entity Framework

I recently ran across this open-source project: http://www.codeplex.com/Sculpture Sculpture is a code-generator which allows you to design your domain model and then use persistence 'molds' such as NHibernate/EF and probably more to generate repositories. It takes care of all the mapping and Data access generation. It looks like it does...

EDMX connection string

so the story is like this. I have a project, called PA.DLL, which have an entity model inside of it (edmx) file. In another project which i'm referencing to the PA.DLL, i copied the connection string that was created (automatically) when creating the edmx file into the main app app.config. however, when i load and run the following l...

Getting access to newly inserted Identity ID before SaveChanges method will be called

I'm using the LINQ Entity Framework and I've came across the scenario where I need to access the newly inserted Identity record before performing multiple operations using procedure. Following is the code sinppet: public void SaveQuote(Domain.Quote currentQuote) { try { int newQuoteId; //Add ...

Entity Framework many-to-many using VB.Net Lambda

Hello, I'm a newbie to StackOverflow so please be kind ;) I'm using Entity Framework in Visual Studio 2010 Beta 2 (.NET framework 4.0 Beta 2). I have created an entity framework .edmx model from my database and I have a handful of many-to-many relationships. A trivial example of my database schema is Roles (ID, Name, Active) Members (...

How do you insert or update many to many tables in .net entity framework

This seems like it should be quite obvious but something about the entity framework is confusing me and I cannot get this to work. Quite simply, I have three tables where the Id values are identity columns: Users (userId, username) Categories (categoryId, categoryName) JoinTable (UserId, CategoryId) composite. In the entities designe...

Does any .NET ORM support localized entities out-of-the-box ?

I need to store localized entities in a database (for instance a Product, which has a Name, which is different in English and Danish). There are several well-known ways to do this, for instance having some sort of a resource table containing the values of the localized columns. However, this does not seem to be very easy to fit into an ...

Entity Framework: Why do navigation properties disappear after a group by?

I retrieve a collection with the following query: var numbers = _betDetailItem.GetBetDetailItems().Where(betDetailItem => betDetailItem.BetDetail.Bet.DateDrawing == resultToCreate.Date && betDetailItem.BetDetail.Bet.Status == 1).Where(condition); Right there I'm able to access my navigation properties and navigate through binded info....

Entity Framework - Detaching entities when ObjectContext disposed?

I'm using the EF in a WinForms app, my idea is to have an ObjectContext per transaction instead of a single long running context. But I'm getting an error when I try to attach objects from a previous transaction into a new one, something to do with the entity already being in another context. I kinda assumed that entities got detached w...

"Metadata information not found" while using EF4's POCO Template?

I just installed the POCO Template for EF4. I have a single entity in my model, AnnouncementText, and the T4 files seem to be properly generated. Attempting to access this new entity is throwing the following error when I access the auto-generated property MyObjectContext.AnnouncementTexts: InvalidOperationException: Mapping and me...

Entity Framework stored procedure not available

I added a reference to a stored procedure in my edmx file, then right clicked on it and selected "Create Function Import", it was added to the Function Imports folder under EntityContainer in the model browser. As I understand it I should be able to use it like so: sampleEntities db = new sampleEntities(); db.SampleStoredProcedure(); ...

NULL values in object properties in Entity Framework

Tables: Article, Author, Comment (1 article and 1 author can have * comments) In the database is 1 article, 1 author and 1 comment. The problem is, that code myBD my_bd = new myBD(); var articles = by_bd.Article; works OK, I can see that an Author and an Article has 1 comment. But that code var comm = (from u in my_bd.Commen...

enforcing ObjectStateManager entry deletion on page leave

I have a edited RESTful wizard based upon Shoulders of Giants | A RESTful Wizard Using ASP.Net MVC… Perhaps? . This wizard has a CANCEL button which, when pressed, fires the code below. // If the user cancels, drop out altogether if (!string.IsNullOrEmpty(CANCEL_BUTTON)) { Session.Remove(VACANCYWIZARD_SESSION_KEY); repository...