entity-framework-4

Delete entity in EF4 without loading the entire entity

风格不统一 提交于 2019-12-08 01:34:22
问题 I am using entity framework 4 and have the following setup and problem. I have a table in MySql with metadata fields an a blob field. Using the Table Splitting technique described here i have divided the table into two entities (DataItem and DataItemDetails). This way I can load all the metadata without loading the blobs. Problem is that when I try to delete a dataitem entity I get this exception: exception: System.Data.UpdateException: Invalid data encountered. A required relationship is

Releasing ObjectContext while using StructureMap

ぃ、小莉子 提交于 2019-12-08 01:18:23
问题 I've been using StructureMap to inject ObjectContext (entities) into my repositories along with lazy-loaded POCO classes. This is my Structuremap registration. For<WebEntities>().LifecycleIs(new HybridLifecycle()).Use(()=>new WebEntities()); I have defined Partial classes against my POCO classes to retrieve info that is not defined in my EDMX schema. e.g. Community.FloorPlanImages would be a getter which filters only the floor plan images from all available Images. Worked pretty well until I

Configure Custom MetadataProvider for ViewModel

不打扰是莪最后的温柔 提交于 2019-12-07 23:44:30
I have a ViewModel for which want to be able to set Metadata properties dynamically. For example I would like to be able to customise the DisplayName and validation error messages using the value of other model properties. I plan to do this with a custom MetadataProvider, following Brad Wilson's article . I want the provider only to be used with selected ViewModels. So my question is, how do I configure that? I have seen examples using ModelMetadataProviders.Current = new MyModelMetadataProvider() , but this would presumably use the custom provider for all model classes entities. Is it

Is my understanding of POCO's + Entity Framework v4, correct?

隐身守侯 提交于 2019-12-07 23:10:22
问题 can someone please confirm/correct me, with my understanding of using POCO's with the Entity Framework v4? If I'm going to want to use POCO's with my EF4 context, do I still need to place/create ENTITIES on the designer/.edmx ? Isn't the idea of using POCO's so I don't need to use those 'heavy' entities? or do i still need those entities, it's just that somewhere else I actually move the data out of the entities and into my POCO's .. which is what gets used by any consuming code? 回答1: If you

Entity Framework mapping of object containing list of same objects

非 Y 不嫁゛ 提交于 2019-12-07 22:53:46
问题 Currently in my code I am doing something like this public class Subject { private List<Subject> _prerequisites; } A subject can have many prerequisites (which are also subjects), and subject can be a prerequisite of many subjects. We were originally using typed datasets to save the data to the database and our tables looked like this: We now want to migrate from using typed datasets to entity framework but I'm not sure how to create the mapping. Generating the EF from the database doesn't

Why the order of params of function imported from stored procedure changed?

萝らか妹 提交于 2019-12-07 21:14:07
问题 I have a stored procedure in SQL Sever 2008 like: ALTER PROCEDURE [dbo].[mySP] @FirstName As varchar(30), @LastName As varchar(30), @ID As int As Begin --...... End then in EF imported this SP as a function like: public ObjectResult<Nullable<global::System.Int32>> MyFunc(global::System.String LastName, global::System.String FirstName,Nullable<global::System.Int32> ID) { //.... } it works fine for long time. Then I add some new thing to EF edmx with "update from database" today, the function

Entity Framework 4: Many to Many relationship IQueryable instead of ICollection

不打扰是莪最后的温柔 提交于 2019-12-07 19:45:58
问题 Good morning everyone, I am trying to tackle a problem I run into with EF code first. My schema is the following public class Article : IUrlNode { [Key] public Guid ArticleID { get; set; } public string Title { get; set; } public DateTime DateCreated { get; set; } public DateTime DateUpdated { get; set; } public string Summary { get; set; } [System.ComponentModel.DataAnnotations.InverseProperty("CategoryArticles")] public virtual IQueryable<Category> ArticleCategories { get; set; } public

How do I SaveChanges on a joined view of 2 or more tables using Entity Framework?

拜拜、爱过 提交于 2019-12-07 19:34:24
问题 In order to get practice with Entity Framework, I am creating a C# WinForms project, and I used the answer to the question in this link to join and display tables in a datagridview: Two entities in one dataGridView I have searched for a clean way to save (to the SQL Server database) the changes made in the datagridview. Is there a good, fast, short, clean way? I have seen some ugly attempts, and even if they work, I am turned off by their ugliness. With one table only (no joins), calling

AD0.NET Entity Framework 4.0 or Linq-to-SQL

若如初见. 提交于 2019-12-07 18:57:07
问题 I am developing a application with asp.net 4.0. My site will be a heavy like more then hundreds of user will be online at a time and lots of content will be there. I have checked both ado.net entity framework 4.0 and Linq-To-SQL with Microsoft.NET Framework 4.0 both are having great improvement over there. I am confused that which one i should use. Performance is one key aspect of my application I don't want to degrade performance of my application via making a bad choice. Could any one will

How do I view an entityset and uncommitted changes?

我只是一个虾纸丫 提交于 2019-12-07 18:46:24
问题 I'm using EF4 and when debugging, I want to see what changes are about to be made to the database. For example, if I add a bunch of new entities, like contacts, I want to see the list of contacts that will be added when .SaveChanges() executes. Likewise, if deletions will occur, it would be nice to see what will be deleted. Is there a visualizer or similar tool in VS2010 that does this? Thanks! 回答1: That is not visible directly. The best place is check ObjectStateManager which holds state