entity-framework-4.1

Split Entity mapping producing unexpected results with oracle database

不羁的心 提交于 2019-12-25 03:48:07
问题 i am currently using the following mapping to map a split entity and is producing unexpeted results it is trying to map a table public class TestResultMap : EntityTypeConfiguration { public TestResultMap() { #region Property => Column Mapping //test table Property(e => e.Id) .HasColumnName("TEST_NUMBER"); Property(e => e.Analysis) .HasColumnName("ANALYSIS"); Property(e => e.ComponentList) .HasColumnName("COMPONENT_LIST"); Property(e => e.Status) .HasColumnName("STATUS"); //result table

Entity Framework Code First - Default values on non-nullable types

一世执手 提交于 2019-12-25 03:37:15
问题 i'm trying to map a legacy database with a legacy POCO model. Since database and model where develop not having in mind Entity Framework there are some little differences between that made me stuck. The challenge I'm facing is that I would like to make it work being as less invasive as possible (don't want to touch code of the database nor the model) since there is too much codes that depends on. I have tried to map the entities using a code first approach, reusing the POCOs from the legacy

Entity Framework 4.1 - default EntityState for a FK?

此生再无相见时 提交于 2019-12-25 02:20:04
问题 I'm having a small problem with ASP.NET MVC and Entity Framework 4. I have an entity called "UF" and another one called "Pais", and they have this relation: UF [* ... 0..1] Pais I can access the Pais object directly from UF using a navigation property: UF.Pais.Whatever = "foobar"; Currently I have a View which inserts a new item into the database, and it has an editor for "Pais.Codigo" ("Codigo" is the primary key for Pais). So when I insert a new UF, the framework creates an instance of

Linq to entities - One to many relationship - need left outer join instead of cross join

坚强是说给别人听的谎言 提交于 2019-12-25 02:19:00
问题 I have the following model: I need a list of all fixtures and predictions (if that fixture has a prediction) for a specific user. The sql to return what I need is as follows: SELECT * FROM Fixture f LEFT OUTER JOIN Prediction p ON f.FixtureId = p.FixtureId WHERE p.UserID = '06E4D3E0-8365-45BF-9054-3F8534C7AD5E' OR p.UserID IS NULL I have tried: var query = from f in c.Fixtures from p in c.Predictions.Where(pre => pre.UserId == new Guid("06E4D3E0-8365-45BF-9054-3F8534C7AD5E") || pre.UserId ==

EF Query with conditional include that uses Joins

给你一囗甜甜゛ 提交于 2019-12-25 01:27:17
问题 This is a follow up to another user's question. I have 5 tables CompanyDetail CompanyContacts FK to CompanyDetail CompanyContactsSecurity FK to CompanyContact UserDetail UserGroupMembership FK to UserDetail How do I return all companies and include the contacts in the same query? I would like to include companies that contain zero contacts. Companies have a 1 to many association to Contacts, however not every user is permitted to see every Contact. My goal is to get a list of every Company

Optional navigation property is not being loaded

给你一囗甜甜゛ 提交于 2019-12-24 17:06:23
问题 I can't for the life of me figure out why Entity Framework (4.1, Code First) is not materializing an optional navigation property. POCOs: public class PlanMember { public Int64 Id { get; set; } public String FirstName { get; set; } public virtual SystemUser CaseManager { get; set; } public String LastName { get; set; } public virtual PlanMemberStatus Status { get; set; } } public class SystemUser { public String EMail { get; set; } public String FirstName { get; set; } public String Id { get;

Visual Studio 2010 crash generating transforming text templates for entity framework

霸气de小男生 提交于 2019-12-24 14:03:03
问题 I have an existing project they I have been using for quite some time. I made some changes in the SQL database and updated the model from the database. When I tried to save the model Visual Studio crashed with the infamous "Restarting error" I checked the event log and it has the following error: Application: devenv.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at EnvDTE

Load most recent related entity record on a list of entities in a single query

人盡茶涼 提交于 2019-12-24 12:00:34
问题 I am using Entity Framework 4.1 with POCOs and DbContext, no proxies no lazy loading. I am very new to Entity Framework and LINQ, but so far very impressed with how simple it is to work with it. I have some basic knowledge of SQL and have built the database first, and then created the model. My problem involves 3 tables (I only left in what is relevant): CREATE TABLE [dbo].[Users]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](50) NULL ) CREATE TABLE [dbo].[UserFriends]( [UserId] [int]

How do I create a POCO object that has 2 references to another class

允我心安 提交于 2019-12-24 09:49:15
问题 I have a table (Event) that can have 2 Locations (main, alternate). Locations can be used in other tables (so no EventId in the locationTable) Using POCO self-tracking, how do I create the reference from the Event table to the Locations table, or what is the best way to handle this situation (I'm having a total brain freeze over this)? (.NET 4.0 C#, EF4.1, MVC 3 being used). Simplified classes: public class Event { public int EventId {get; set;} public string Tile {get; set;} public int

In EF4.1+, do you have to expose a foreign key property on a dependent entity to enforce an identifying relationship?

☆樱花仙子☆ 提交于 2019-12-24 09:24:01
问题 If I want to create an identifying relationship using EF 4.1+ (or EF5 Beta), does this mean I have to expose a foreign key property on the dependent entity? When using the Fluent API? And when the DbContext is in a different project than the Entity? I can't see any other way to do it. The DbModelBuilder needs to know the foreign key property in order to include it as part of the primary key. However if the property is not exposed, and the Entity & DbContext implementations are in different