entity-framework-4

EF4 DAL design and the ObjectContext: Argument with co-worker

Hello all. I work with a senior developer who is a guru .NET architect. We have had many constructive arguments over the last 6+ months and generally I concede defeat in most of our discussions. I have learned stacks from working with him. There is one design problem we are currently in disagreement with, however, and I would like some ...

How implement a Master Detail in a Web Form using Entity Framework

Hi everybody, i', starting to work with Entity Framework and i would like to know how to implement a master detail web form that permit the user to insert the details in a datagrid before saving it to the database using entity framework 4. Thanks in advance. Jean Carlos ...

Changing Inherited Types in Entity Framework

I see there is a similar question asked here but I don't think it was very clear so I'm creating another : http://stackoverflow.com/questions/1239504/entity-framework-inheritance-change-object-type I have an Entity Student that inherits from an Entity Person. At some point a Person could become a Student. Is there any way in Entity Fr...

How to include ampersand in connection string password when using Entity Framework?

I'm using Entity Framework 4 for a simple app and would like to bake my connection credentials into the following connection string: <connectionStrings> <add name="MyEntities" connectionString="metadata=res://*/MyDataModel.csdl|res://*/MyDataModel.ssdl|res://*/MyDataModel.msl;provider=System.Data.SqlClient;provider conn...

Examples for Entity Framework 4: Mapping POCOs to EAV database?

Our customer advertises products but the product's attributes are vastly different from one another. There are almost as many product "classes" as there are products. Originally, we created an EAV database where we added and removed attributes for each "class" of product. The whole thing works very well, but the complexity is mind num...

Entity Framework 4 Function Import not working

I am using Entity Framework 4 with the POCO code generator. I have a stored procedure that does an INSERT and returns the @@IDENTITY of the inserted record. I am trying to import the stored procedure as a function in my .edmx file, but I am having trouble using it. In the model browser, I can see the stored procedure under the database ...

Custom serialization/deserialization over a field with Entity Framework 4

Hi all, I'm in charge to migrate our own DAL to a solution based on Entity Framework 4 but, before I can do it, I need to be sure it's possible to translate all our "constructs" to this new technology. One of the biggest issues I'm having is the possibility to read a field and build a custom type. Valid examples could be a bit mask sav...

The place of Entity framework 4.0 + POCO + WCF in DDD "world".

I'm trying to get to light. In DDD approach we have Presentation Layer(UI), Application Layer(Application Services), Domain Layer and Infrastructure. I'm sure that anyone knows o short description on those 4 layers. I know WCF feet in Application Layer(Application Services), and the Entity Framework .edmx model in Infrastructure Layer....

I Can't add or remove using ria services in my SL4 project

Hi .. I built this SL4 project .. and it was working perfectly, after while I re-opened the project and pressed F5 to try it again. After I add new item in Data Form, filling the required field and doing "SubmitChanged()" I get "Code : 4004 error message" . I'm using Entity Framework + RIA services, I used EF profiler to see if the Li...

Assembly reference error with C# EF4 and a layered design.

Hi all, I'm finally getting around to checking out the latest EF release and I'm running into some troubles with my testing. So, my DAL layer holds my .EDMX file and I'm using the MS POCO template so I also have the generated .TT files and classes. I have a generic base class in the TestProject.DAL I've created that those classes deri...

Weird behavior with the ObjectStateEntry's State

Hi all, I have the following extension method and i'm not sure why each entrys state is being changed to Unchanged after i call entry.AcceptChanges() on one entry. public static void SaveWithLogging(this ObjectContext context) { IEnumerable<ObjectStateEntry> entries = context.ObjectStateManager.GetObjectStateEntries(Ent...

Entity read stored procedure mapping?

So I have a customer requirement to only use stored procedures for all database operations. I created CRUD stored procedures for each of my tables, and then created my Entity models. So I see easily how to map my Insert, Update and Delete stored procedures to my entity (Customer for example), but there seems to be no way to map my Sele...

Self-tracking entities Silverlight proxy generation

Hi guys! I’m developing a Silverlight 4 application using STE with EF4. I created a Silverlight project with all the Entity classes generated with my STE T4 template and build properly on VS. But when I add a WCF proxy with Visual Studio and check the “Reuse types in reference assemblies” (having a referece to my Client.Model assembly w...

LINQ2SQL vs EF4: Entity retrieval and usage from different contexts

Hi I am long time user of LINQ2SQL, but have not used the Entity Framework yet. One thing that is not possible in LINQ2SQL is to use tracked entities in different data contexts, or 'link' objects from different data contexts. Example: Foo f = null; using (var dc = new DB()) f = dc.Foos.Single(x => x.ID = 1); using (var dc = new...

linq to entities case sensitive comparison

This isn't a case-sensitive comparison in Linq to entities: Thingies.First(t => t.Name == "ThingamaBob"); How can I achieve case sensitive comparison with Linq to entities? ...

How can I use Castle Windsor instead of this?

I have a basic working knowledge of Castle Windsor, but I cannot figure out the DI equivalent of the below code ... private static DbModel BuildModel() { var builder = new ModelBuilder(); var types = Assembly.GetExecutingAssembly().GetTypes(); foreach (var type in types) { if (type.Na...

Why is there no implementation for the methods of StructuralObject?

I am looking up methods of the System.Data.Objects.DataClasses.StructuralObject in Reflector and I see that there's no implementation for any of the methods. I understand that some of the methods such as most of the SetValidValue overloads have been marked as reserved for future use, as stated by their documentation. But even the other...

EF4 Include not returning any of the navigation properties

Hi all, I am using this public IQueryable<Document> GetDocuments() { return this.ObjectContext.Documents.Include("Company").Include("PostingStatus").Include("DocumentType").Include("Period"); } in my domainservice but its not returning anything to the client i am using WCF RIA Services and EF4 and Silverlight. Doe...

WCF RIA Services and Optimistic Concurrency

I have a WCF RIA service app that in one of its services Insert method I should assign an incremental identification code to a property of its entity from the previously added record. I use SQL server and Entity framework in DAL. How can I avoid optimistic concurrency in such situations and assign the code without the knowledge of the ...

Business logic in Entity Framework POCOs using partial classes?

I have business logic that could either sit in a business logic/service layer or be added to new members of an extended domain class (EF T4 generated POCO) that exploits the partial class feature. So I could have: a) bool OrderBusiness.OrderCanBeCancelledOnline(Order order) .. or (IOrder order) or b) bool order.CanBeCancelledOnline(...