entity-framework-4.3

JqGrid DataBinding exception while exporting to excel file

三世轮回 提交于 2019-12-25 05:03:35
问题 I am trying to export JqGrid to excel so i follow this instruction and i use it like at below. var grid = new JqGridModelParticipiant().JqGridParticipiant; var query = db.ReservationSet.Select(r => new { r.Id, Name = r.Doctor.Name, Identity = r.Doctor.Identity, Title = r.Doctor.Title.Name, Total = r.TotalTL, Organization = r.Organization.Name }); grid.ExportToExcel(query,"file.xls"); And i get below exception on the line of " grid.ExportToExcel(query,"file.xls");" Data binding directly to a

Run entityframework cmdlets from my code

强颜欢笑 提交于 2019-12-24 23:35:31
问题 I am creating a small program over entityframework which allows to edit the POCOs with a UI. as part of the process i would like to call the "add-migration" command from my code to save the interaction of the rest of the programmers with the program manager console. is it possible at all? thanks 回答1: Add-Migration cmdlet is defined in separate EF 4.3 Powershell assembly used by Package manager console. This assembly references a real EF 4.3 assembly. The core logic exposed from that assembly

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

EntityFramework anonymous composite key property name conflict

天涯浪子 提交于 2019-12-23 08:49:14
问题 I'm using EntityFramework 5 (or 4.3 for .Net Framework 4.0) In my DbContext object I have already set the correct DbSets and the objects contain proper references to each other. This is not new for me, and things are working well. Now in this case I have some composite keys that, sometimes, include the foreign key of a table (or object in this case). For this I use the HasKey<>() function on the OnModelCreating method of the DbContext. When these properties have different names, there is no

How do I get Entity Framework 4.3 Code First to map a subclass using Table Per Type (TPT)?

▼魔方 西西 提交于 2019-12-23 02:57:06
问题 I'm using EF 4.3 Code First and automatic migrations. I have the following 3 classes: public class BaseUser { [Key] [MaxLength(50)] public string Username { get; set; } [MaxLength(200)] public string Password { get; set; } } public class AdminUser : BaseUser { public int SettingsFlag { get; set; } } public class RegularUser : BaseUser { public DateTime LastLogin { get; set; } public DateTime LastSummary { get; set; } [MaxLength(100)] public string Email { get; set; } public int CompanyID {

Fetching complex objects by raw SQL query in Entity Framework

半城伤御伤魂 提交于 2019-12-22 05:34:20
问题 I would like to fetch from database complex object using single query. Let's look at the following example: SELECT TableA.*, TableB.* FROM TableA INNER JOIN TableA.B_Id = TableB.Id and corresponding classes: public class QueryResult { public TableA A { get; set; } public TableB B { get; set; } } public class TableA { public int Id { get; set; } public string SomeContentA { get; set; } public int B_Id { get; set; } } public class TableB { public int Id { get; set; } public int SomeContentB {

Cannot update many-to-many relationships in Entity Framework

只愿长相守 提交于 2019-12-22 05:29:32
问题 I am using Entity Framework 4.3 Code First, and I have problem with updating many-to-many relationships. I defined the following classes: public abstract class Entity { [Column(Order = 0)] [Key] public int Id { get; set; } [Timestamp] [Column(Order = 1)] public byte[] Version { get; set; } } public class Video : Entity { public string Title { get; set; } public string Description { get; set; } public TimeSpan Length { get; set; } public virtual ICollection<Coworker> Coworkers { get; set; } }

EF 4.3 Migration - how to produce a downgrade script?

吃可爱长大的小学妹 提交于 2019-12-21 07:37:49
问题 I have an issue which I could not find answer for across the web. I am using CodeFirst EF 4.3.1 Migrations with MsSQL. I have added several migrations and now I want to produce a script for upgrade/downgrade between two migrations. For upgrade I run the following command which successfully reproduces an upgrade script: PM> Update-Database -Script -SourceMigration:"201205161144187_AddPostAbstract" -TargetMigration:"201205161203310_BlogLimitsAndTableRename" However, for downgrade I run the

Entity Framework with NuGet - Import-Module error in init.ps1

放肆的年华 提交于 2019-12-20 07:28:36
问题 Here is the complete error message that I get in the Package Manager Console when starting VS2010: Import-Module : The specified module 'C:\Users\adam.assman\Project\packages\EntityFramework.4.3.1\tools\EntityFramework.psd1' was not loaded because no valid module file was found in any module directory. At C:\Users\adam.assman\Project\packages\EntityFramework.4.3.1\tools\init.ps1:13 char:14 I've installed Entity Framework using NuGet, on a DLL/ClassLibrary project in my solution. The startup

IValidatableObject is useless for EF navigation properties?

走远了吗. 提交于 2019-12-19 11:56:14
问题 IValidatableObject.Validate only gets called when the implementing entities DbEntityEntry.State differs from "Unchanged". And just changing a navigation property won't change the state and so the validation will never occur. Why Microsoft always releases half-baked beta things? I cannot even detect the navigation property change by hand: var changes = context.ChangeTracker.Entries() .Where(e => e.State != EntityState.Unchanged) .ToArray(); Returns an empty array. 回答1: There are a few