entity-framework

EF Mapping and metadata information could not be found for EntityType Error

Hi, I have encountered an exception when I using Entity Framework 4.0 RC. My Entity Framework model is encapsulated in a private assembly whos name is Procurement.EFDataProvider and my POCO are inside of another assembly Procurement.Core The relation between Core(Business Logic)and EFDataProvider(Data Access) is with a factory named Data...

Entity Framework Specification Pattern Implementation

How-to implement Specification Pattern with Entity Framework ? ...

Entity Framework 1.0 combined key from the same table

I have the User table with id userId. Then I have KnowUser table which contains data which user know some other user. This table have two foregin keys on User table as a combined primary key. So: User Id PRIMARY KEY Name KnowUser UserId FK on User UserKnowId FK User Years PRIMARY KEY(UserId, UserKnow) When do I import those tables ...

Entity framework - Problem when cloning entities. reference entities are cloned as wel

Hi, I have a TreeNode class with Expression. Expression has Parameter ID pointing to Parameters table. Each parameter has ParameterGroupId. I have a Copy& paste TreeNode feature. When I copy an existing node, I create a new node but using the same reference to the P (Parameter) and PG (ParameterGroup). The problem is, the new node was...

Why would WPF / Entity Framework give me a AspNetHostingPermission error when reading .MDF file?

I have a WPF application which uses LINQ-to-SQL to access an .MDF file within its local directory structure. This works fine. However, when I create a second .MDF file in the same directory as the first, and try to create a model with Entity Framework, it gives me this error: Request for the permission of type 'System.Web.AspNetHo...

How do I bind multiple dropdowns in my ASP.NET MVC Edit Page?

I have a viewmodel that contains a number of properties, a SelectList, and an array of child objects. public class RoundViewModel { public int RoundId { get; set; } public string RoundName { get; set; } public SelectList Teams { get; private set; } public List<GameViewModel> Games { get; set; } } public class GameViewMo...

Why would Entity Framework be able to retrieve entities but not save/update/delete them?

I have a WPF app with a local .MDF file on which I created an Entity Framework class model. Retrieving entities from the database works fine: //get entities using (var context = new TestDataEntities1()) { var customers = from c in context.Customers select c; foreach (var customer in customers) { ...

compare the dates with linq

I have this code: i.SpesaVitto = db.TDP_NotaSpeseSezB.Where(p => p.GiornoFine == null && ((DateTime)p.Giorno).Date == ((DateTime)i.Data).Date && p.MissioneID == missioneID).Sum(p => p.Costo); If i launch it i obtain this error: The specified type member 'Date' is not supported in LINQ to Entities. ...

How to dynamically load connection string from web.Config in Entity Framework 4.0?

In LinqToSql I could write an empty constructor if I set the Connection string to (None). In that empty constructor I could then pull the connection string from the web.Config like so: public CustomDataDataContext() : base( ConfigurationManager.ConnectionStrings[ "DB" ].ConnectionString, mappingSource ) { OnCreated(); } I am t...

date difference with linq

With this code i.SpesaAlloggio = db.TDP_NotaSpeseSezB.Sum(p => p.Costo / (((DateTime)p.DayEnd).Subtract((DateTime)p.DayStart).Days + 1)); i receive this error: LINQ to Entities does not recognize the method 'System.TimeSpan Subtract(System.DateTime)' method, and this method cannot be translated into a store expression. How can i ...

Entity Framework, Junction Tables with Timestamps

I was wanting to know if there is a good way to work in timestamps into junction tables using the Entity Framework (4.0). An example would be ... Clients -------- ID | Uniqueidentifier Name | varchar(64) Products ----------- ID | uniqueidentifier Name | varchar(64) Purchases -------- Client | uniqueidentifier Product | uniqueident...

ADO.net entity framework - Custom code

I am investigating some OR/M's and have been unable to find an answer to this question. I am currently looking at Microsoft's ADO .net entity framework. Can I override (or use partial classes) to insert custom code into the entities that are created from the database? It appears that the entities are generated using Xml (not my favour...

How do I connect my data access methods to my asp.net UI?

Hi there, I am seriously at a loss here. The three things that will not change in this project are the fact that we are using the Entity Framework to do our data access, the fact that we want thorough unit testing and that our UI is asp.net. My question is how the hell do you make this work in Asp.net? E.g. You can use an ObjectDataSou...

Getting data out of a model made of multiple tables in a one-to-many relationship

Hi, I've got a relatively simple question about asp.net MVC models. I've got a model based on two tables that are linked in a one-to-many relationship. table AnimalGroup(ID,name) table AnimalSubGroup(ID,name,AnimalGroupID) Each AnimalGroup has any number of AnimalSubgroups. How do I iterate through each AnimalGroup's AnimalSubGroup...

Using Entity Framework 4.0 with Code-First and POCO: How to Get Parent Object with All its Children?

I'm new to EF 4.0, so maybe this is an easy question. I've got VS2010 RC and the latest EF CTP. I'm trying to implement the "Foreign Keys" code-first example on the EF Team's Design Blog, http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx. public class Customer { public int Id { get; set; publi...

Unknown server tag 'asp:EntityDataSource'

I uploaded my files to my remote server having support for ASP.Net 3.5. Website is developed using ASP.Net 3.5 and Entity Framework. Also i copied the dlls to bin folder. But i am getting the following error arser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the fo...

Get changes to entity after update in database

I do this to save new invoince in my Invoices database table: // insert invoice into EDM edmx.AddToInvoices(newinvoice); // save EDM changes to datastore edmx.SaveChanges(); I have a trigger on one of the columns that gets computed dynamically by the database. What is the...

WCF SOA: CRUD Data Access Service...why bother (or is our design wrong)?

Hello all again. We have a Data Access service in our SOA WCF system. This service is responsible for doing CRUD (create, update, delete) operations on "system wide" database tables, and is also the source of this data for queries. Any other service in the system wanting to access the tables under the contol of the DAS have to go to the...

Entity Framework 4.0: Adding scaler property gives error (property it not mapped: 11009)?

Hi there, I wanted to add a new property to one of my model (table). Basically its a property that doesn't exist in the database but i need to add it to my model so that the custom generation tool (self tracking entity generator) will create the the property inside the the custom generated file. I added a scaler property, its a string ...

Entity Framework 4.0: Adding a property on a table to hold a entity from another table?

Hi there, I wanted to create a new property on a table in my model.. Basically i have a table called contract which has lots of fields, but i want to add another field called client which will hold my other table called client.. I tried playing around with complex types but i don't know if this is it.... Then i found navigation propert...