entity-framework

Are protected entity properties in EF 4 a bad idea with data services?

After some NullReferenceException headache from deep down System.Data.Services I found out that data services doesn't like properties in the EF model marked as protected. The exception occurs when the data service is initializing and tries to generate metadata for the EF model. Apparently Microsoft decided to throw a NullReferenceExcept...

Entity framework date/time conversion for sqlserver

I prefer working with DateTime.MinValue, even if I use SqlServer as backend. Is it possible to make EntityFramework to convert from DateTime.MinValue to 1753-01-01 when saving entities and convert back to DateTime.MinValue when fetching them? Edit: I do not want to use DateTime? (nullable value type) ...

Why should I use nhibernate instead of entity framework 4

I'm trying to convince my client to use nhibernate instead of Entity Framework 4. My client have decided to use only Microsoft libraries (including Unity and Enterprise library 5). I don't agree with them (there are so much better logging frameworks/validation layers/ioc etc) but respect their decision. I've played with EF4 for a couple...

EF 4.0 - Load Navigation Property of Navigation Property

I am attempting to perform the LoadProperty operation from my context to load a navigation property of a navigation property. My setup is that I have an EntityA, which contains a list of EntityB's, and each EntityB contains a list of EntityC's. I am doing the following programatically: public virtual List<T> LoadProperty(List<T> entiti...

Entity Framework MVC View Problem

Function Edit(ByVal id As Integer) As ActionResult Dim entities As New Deployment_devEntities() Dim w As System.Data.Objects.ObjectQuery(Of tblWebsites) = entities.CreateQuery(Of tblWebsites)("SELECT VALUE m FROM tblWebsites as m WHERE m.WebsiteID = " & id) Dim q = From m In entities.tblWebsites Where m.We...

How to fix “The ConnectionString property has not been initialized” in nopCommerce

Hi Guys, I'm trying to integrate nopCommerce into a third party system but am hitting a problem when I try to access any nopCommerce pages. Because I'm integrating with a third party system I've had to merge web.configs and copy all files over. I have a standalone install of nopCommerce aswell and that is running fine. Any help would b...

EF CTP4: For Code Only, no database generation needed, how much DB info is needed?

I have a database, and I have entity POCO's, and all I want to use EF for is to map between the two and keep track of changes for loading, saving, etc. I have been reading a lot of the literature (such as it is) on "Code First", and I am unclear on how much of the database information I need to supply when there is not going to be a dat...

Entity Framework 4 Many to Many Binding

The Entity Framework 4 is driving me mad, This situation is: Employee entity - many to many association - Department entity I get employees from the EmployeeRepository and Departments from the DepartmentRepository. Each repository uses its own data context. My UI has a list of departments (from the DepartmentRepository) to select for ...

How to declare one to one relationship using Entity Framework 4 Code First (POCO).

How to declare a one to one relationship using Entity Framework 4 Code First (POCO)? I found this question http://stackoverflow.com/questions/2089395/one-to-one-relationships-in-entity-framework-4-v2-with-poco, but the article that the answer references was not useful (there is one line of code that is a 1-1 relationship, but no mention...

LINQ to SQL: How does EntitySet lazy load objects?

Hello, I've been trying to implement a custom ORM for our project and am interested to learn how LINQ to SQL or Entity Framework lazy load objects. I read some about EntitySet and realized it has a Load() method. Does anyone know how exactly Load works? I'm assuming it should have a reference to DataContext (or ObjectContext in EF) t...

Entity Framework - related ICollection getting materialized into HashSet

I use EntityFramework POCO + proxies + lazy loading in my project. Today I was pretty surprized to see that the class Transaction has its related collection Rows materialized into HashSet (instead of EntityCollection). I need EntityCollection for tracking changes in the collection. public class Transaction { public virtual ICollecti...

Is it possible to see added entities from an unsaved EF4 context?

I'm just getting into Entity Framework 4, and was eventually hoping to wrap it in a repository pattern using POCOs. I discovered something that I wasn't expecting though. It appears that if you create a context, add an object to it (without saving the context) and query the context again, it doesn't include the new object in the results....

ActiveSync keeps trying to download the changes it just uploaded

I am using ActiveSync with the Entity 4.0 framework. Everything is working fine except that after the ActiveSync posts updates to the server, it then tries to download those same record updates back to the client. This triggers key constraint errors, as it should. The only changes I have made is deleting all the ActiveSync fields from t...

WPF ObjectContext Attach Detach - Not Working

Hello, I am implementing an ObservableCollection to manage my EF entities. When i want to edit some entity, i create a clone of the entity and i open it up inside a popup window. When the user finishes to edit the cloned entity, i proceed to detach the original entity and then attach the new (cloned and edited) entity. No exception occ...

question about EF 4

i have a 2 tables in db . Person and child they are hirarchy it means my child table has an Id that is PRIMARY KEY but not auto inceremental.this Id fill by Id of Parent table i have created a EDMX from these but when i wanna save a child i cant see the fields of parent in my child class in EF its not supported ? i wanna does it like N...

SQL generated by LINQ for logging

Hi all. Plz help. I have this query and its result implements IEnumerable. RoutesEntities routesModel = new RoutesEntities(); LocalesEntities localesModel = new LocalesEntities(); var routesQuery = from rs in routesModel.Routes.ToList() join ls in localesModel.Locales.ToList() on rs.LocaleID equal...

Is it double work creating a data access component and business component?

I am designing my first Layered Application which consists of a Data, Business, and a Presentation layer. My business components (e.g, Business.Components.UserComponent) currently has the following method: public void Create(User entity) { using (DataContext ctx = new DataContext()) { ctx.Users.AddObject(entity); ...

MySQL connector EF stored procedure

I have the following stored procedure: CREATE PROCEDURE GetSequenceNextValue(IN sequenceName VarChar(100)) BEGIN UPDATE Sequences Set currentValue = LAST_INSERT_ID(CurrentValue + 1) WHERE name = sequenceName SELECT LAST_INSERT_ID(); END But when I update my model, this procedure is not imported even into storage model. ...

Entity Framework + Unity Framework

Hello, I beginning a new project and I need to create a Project for implementing Entity Framework 4.0 and Unity Framework 2.0 along with Enterprise Library 5.0. I am very new to Entity Framework and Unity Framework and getting confused in how I can get normal Object BO's and DAL with Database. Can someone point me to some simple exampl...

ASP.NET & Entity Framework 4.0 data not refreshing on screen

I've written a 2-tier C# asp.net application. Everything works OK, but if I modify the SQL Server data using the management console, the changes are not displayed on screen. It seems the application reads the data from a cached instance. I have tried everything to make sure it's not a browser cache issue... the data remains static until ...