entity-framework

Why isn't Entity Framework recognizing my procedure?

I am trying a function import, and EF doesn't recognize my procedure. That's it: ALTER PROCEDURE dbo.AddNewTicketFieldOption ( @ticketFieldID INT, @optionID INT ) AS BEGIN INSERT INTO tbTicketFieldOptions (cdTicketField, cdOption) VALUES (@ticketFieldID, @optionID) --only to return something, EF hack SELECT 0 ...

Loading a nested repeater with Data from 2 Entity Framework Queries

I have 2 tables A and B that have a many to many relationship. I am using nested repeaters to show the data in a web page. My issue is, how do I write an ObjectQuery or an IQueryable query that returns the parent rows in A and the child rows in B so that I can use them as my data sources for my inner and out repeater. I have the code ...

Entity Framework Model and ASP.NET MVC 2 Preview 2: Problem with umlauts

HI! I have this piece of a HTML in a View: <% foreach (var item in Model) { %> <tr> <td> <%= Html.ActionLink("Edit", "Edit", new { id = item.HändlerID })%> </td> <td> <%= Html.Encode(item.HändlerID) %> </td> <td> <%= Html.Encode(item.HändlerName) %> ...

FixUp-esque Collection for NHibernate?

Hello, I'm working on getting started with NHibernate on a large scale project (have worked with it in small-scale before), and am digging into the issue of managing relationships... specifically, what best practices are out there for doing so? Example: The classic: you have a Blog and Comments, the blog points to (0-n) comments, each ...

Entity Framework - setting values

So I query my object from the db (via entity framework) and I decide to set some values. Let's say the values I set are the same as they were originally. What's happening is that the ObjectStateManager is detecting that my object is 'Modifed'. I was hoping that the property change event would do an equals comparison and only set the v...

GetUTCDate with Entity Framework

I saw this question (http://stackoverflow.com/questions/1888004/entity-framework-getutcdate): "Can I use the SQL-function getutcdate() from entity framework to set a date field in the database when saving an entity object?" with this answer from Craig Stuntz: "Yes, you can do this. The CLR function DateTime.UtcNow is mapped to the canoni...

C# - Entity Framework - Understanding some basics

Model #1 - This model sits in a database on our Dev Server. Model #2 - This model sits in a database on our Prod Server and is updated each day by automatic feeds. I have written what should be some simple code to sync my feed (Model #2) into my working DB (Model #1). Please note this is prototype code and the models may not be as...

How to remove circular reference in Entity Framework?

Hi, The circular reference between my Customer and Order entities caused a exception during serialization. Is there anyway to force EF to generate one-direction reference between these two entities? Thanks in advance! ...

Can't I call a stored procedure from Entity Framework inside a transaction scope?

I have a method that uses Entity Framework to do some changes/inserts in different entities, all this inside a single transaction scope. These changes works very well. My problem has began when I needed to use a stored procedure in the middle of these operations. The procedure does only an insert in one table, and has no explicit declar...

ADO.NET Data Services - propagate changes across tracked lists?

So here is the situation. I am using ADP.NET Data Services 1.5 CTP2 with Silverlight 3. My EF data model is (in short) like this: CmsProfile Id Name CmsEvent Id Title CmsProfileEventLink Id ProfileId EventId So there is a many <-> many relationship between people and events. When I load the ...

Entity Framework in Silverlight - many procedures or one universal?

Hi, I'm trying to write an silverlight app which operates on database through a web service. For now I don't know how many tables will be in the database but I think it will be about 25. Every insert,update,delete on the database should be overriden by my algorithms but almost the same for every table. a) If I insert data as a result I ...

LINQ generating SQL with duplicate nested selects

Hi. I'm very new to the .NET Entity Framework, and I think it's awesome, but somehow I'm getting this strange issue (sorry for the spanish but my program is in that language, anyway it's not a big deal, just the column or property names): I'm doing a normal LINQ To Entities query to get a list of UltimaConsulta, like this: var query = ...

SqlException from Entity Framework - New transaction is not allowed because there are other threads running in the session.

I am currently getting this error: System.Data.SqlClient.SqlException: New transaction is not allowed because there are other threads running in the session. while running this code: public class ProductManager : IProductManager { #region Declare Models private RivWorks.Model.Negotiation.RIV_Entities _dbRiv = RivWorks.Mode...

How To Remove Foreign Key Reference In Entity Framework

Hi, I'm updating my model which is built by entity framework. I removed a entity from the designer and then there pops up a error said "Foreign key constraint 'FK_Table1_Table2' ... no mapping specified for the table Table2. Now I really don't want to map Table2 into entities. What should I do to clear the edmx and avoid such error? Can...

How to make string as primary key in entity framework!

I have a legacy table containing employee name and employee id. Now the employee id is in char because it can hold values starting with an alphabet. Employee id is the only unique field available in the table. Now I am using a view to capture the data from the table (It is in a separate database). But my entity framework is refusing to ...

Self Tracking Entities (STE)'s and partial updates with EF4 and mVC2

I have an MVC2 app where I am starting to use the STE's. I am looking for some clarification on how updates should work. Background: If I have a Blog entity with related category entities and Related post/comment entities. In MVC I am rendering a view with the main Blog entity and the categories but not the related posts. When I pos...

Return Tuple from EF select

How can I retrieve Tuples at Select using EF4? var productCount = (from product in context.products select new Tuple<Product, int>(product, products.Orders.Count)); Or var productCount = (from product in context.products select Tuple.Create(product, products.Orders.Count)); En...

Access SQL Server 2008 Change Tracking Info via Entity Framework

Based on this link it looks like I can get date inserted / date modified information "for free" (without the need for triggers etc.) using Sql Server 2008 by simply enabling Change Tracking. I am using Entity Framework to access the data. My question is, how do I access date modified / date inserted information for the database records...

Entity Framework and LINQ Include()

Hi I am new to Entity Framework and LINQ and have run into a rather odd scenario. I have been using the following query to return account information: var account = ((from acct in _entities.Account join m in _entities.Item on acct.Id equals m.Account.Id where acct.Id == accountId && m.It...

Get just Count values from EF

I have a People table, I want a method that return one Person by id, with numbers of Cars, number of houses, etc. I need to Load this tables together? I see SQL generated by EF, is a monster. Ex: public Person Get() { return context.People.Include("Cars").Include("Houses").Where(x=> x.Id = 1).First(); } My view use this: Name: ...