entity-framework-6

Entity Framework will only set related entity property to “null” if I first get the property

烂漫一生 提交于 2019-12-30 10:13:49
问题 Edit This seems to occur for any Entity property that references another entity in one direction. In other words, for the below example, the fact that Bar overrides Equality appears to be irrelevant. Suppose I have the following classes: public class Foo { public int? Id { get; set; } public virtual Bar { get; set; } } public class Bar : IEquatable<Bar> { public int Id { get; set; } public override bool Equals(object obj) { var other = obj as Bar; return Equals(other); } public bool Equals

The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file

社会主义新天地 提交于 2019-12-30 08:02:05
问题 I have an asp.net solution using entity framework 6 to mysql server. now I have to work on that solution on a new machine, but I have some problems: 1) when building the solution I get error: "The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file". App.config: <entityFramework> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6,

EntityFramework CodeFirst: CASCADE DELETE for same table many-to-many relationship

旧街凉风 提交于 2019-12-30 04:28:07
问题 I have an entry removal problem with the EntityFramework and a many-to-many relationship for the same entity. Consider this simple example: Entity: public class UserEntity { // ... public virtual Collection<UserEntity> Friends { get; set; } } Fluent API Configuration: modelBuilder.Entity<UserEntity>() .HasMany(u => u.Friends) .WithMany() .Map(m => { m.MapLeftKey("UserId"); m.MapRightKey("FriendId"); m.ToTable("FriendshipRelation"); }); Am I correct, that it is not possible to define the

How can I get a PDB file for the EntityFramework NuGet package?

不羁的心 提交于 2019-12-30 01:36:32
问题 I'm trying to debug a StackOverflow in the EntityFramework NuGet package (version 6.1.3). In order to see the stack frames I need the PDB file for EntityFramework.DLL and EntityFramework.SqlServer.DLL. However, I can't seem to get Visual Studio to download this from either the MSFT symbol sources or from SymbolSource.org (I can get other System PDBs and things like NewtonSoft.json). Are the EF PDBs available anywhere? 回答1: Now with pictures (as it took me about an hour of trial and fail) Get

C# Generic Passing different objects with same properties

回眸只為那壹抹淺笑 提交于 2019-12-29 09:04:25
问题 I am not sure if what I am doing is possible. I have 2 methods. The body of the 2 methods are exactly identical, however the signature of the method both parameter and return are different. The passed in parameter's properties are changed and the object are different but have the same property name (They are two different Entity Framwork Entities). Inheriting both from a base object is not possible (i think) because these are Entity Framework Entities. Best to show example then talk about it.

Add Column Name Convention to EF6 FluentAPI

做~自己de王妃 提交于 2019-12-29 08:57:20
问题 This question was asked here 4 years ago: EF Mapping to prefix all column names within a table I'm hoping there's better handling these days. I'm using EF6 Fluent API, what I'll call Code First Without Migrations. I have POCOs for my models, and the majority of my database column names are defined as [SingularTableName]Field (e.g., CustomerAddress db column maps to Address field in Customers POCO) Table: CREATE TABLE dbo.Customers ( -- ID, timestamps, etc. CustomerName NVARCHAR(50),

Using include doesn't change the behavior

筅森魡賤 提交于 2019-12-29 08:37:16
问题 Could Someone help me to clarify the difference between : var query = awlt.People.Include(p => p.EmailAddresses) .Where(p => p.LastName.Equals(lastName)) .SelectMany(a => a.EmailAddresses) .Select(a => a.EmailAddress1); var query = awlt.People .Where(p => p.LastName.Equals(lastName)) .SelectMany(a => a.EmailAddresses) .Select(a => a.EmailAddress1); I get the same results in both cases without knowing the difference . Does the Eager Loading require using Include ? 回答1: The both query are

Entity Framework Code First truncating my decimals

不想你离开。 提交于 2019-12-29 07:28:27
问题 I am using Entity Framework 6.x using the Code First approach on an MVC 5 application. In this particular situation my model (among other things) contains two properties named Latitude and Longitude: [Required, Range(-90, +90)] public decimal Latitude { get; set; } [Required, Range(-180, +180)] public decimal Longitude { get; set; } And when I performed the migration I got something like this CreateTable("ResProperty"), c => new { : Latitude = c.Decimal(nullable: false, precision: 10, scale:

Entity Framework - Unable to load the specified metadata resource

孤者浪人 提交于 2019-12-29 04:09:55
问题 I realise that this has been asked a number of times but I just can't seem to get the bottom of my issue. I'm getting the following error stack: When I reflect out my dll I can see the following Reading http://blogs.teamb.com/craigstuntz/2010/08/13/38628/ it suggests I'd expect to see the csdl, msl and ssdl files here, but they're not. They do exist here obj\Debug\edmxResourcesToEmbed though. Never-the-less I tried to explicitly tell the web.config where to look by doing this: ..

Does Entity Framework 6 support .NET 4.0?

主宰稳场 提交于 2019-12-28 05:56:08
问题 I believe Entity Framework 6 is intended for .NET 4.5. I'm wanting to use it for a Visual Studio 2010 project, so .NET 4.5 isn't available. Does it support .NET 4.0 and hence Visual Studio 2010? 回答1: Entity Framework 6 does support .NET 4.0. You should update your version of NuGet then try again. You can find the download at http://www.nuget.org/. I successfully downloaded EntityFramework 6.0.0-rc1 from the main nuget.org feed from an application targeting .NET 4.0 回答2: Entity Framework