ef

EF with POCO + WCF + WPF. Reuse POCO classes on client or use DTOs?

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We are developing a 3-tier application with a WPF client, which communicates through WCF with the BLL. We use EF to access our database. We have been using the default EntityObject code generator of EF, but had lots of problems and serialization issues when sending those object through the wire, and when processing and reattaching them in the BLL. We are about to switch to the POCO template, and rewrite the data access and the communication parts of our app (we are hoping to have a cleaner architecture and less "magic code" that way. My

EF 4.3 Code First Migrations - Uncompress __MigrationHistory Model

匿名 (未验证) 提交于 2019-12-03 01:46:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: How can I uncompress/read the compressed models stored in the EF 4.3 Code First Migrations __MigrationHistory table? I found a hint in this comment , that I can uncompress it using zip/gzip, but I don't know how exactly I should do this. The problem is that I have changed something in my ef model classes, but when I call "add-migration" an empty migration ist generated. I think that is because the changes of my model classes are already assigned to an existing migration :( 回答1: (this may be a good starting point - won't work in

EF 4.1 / Linq-to-SQL: What is better: using Equals or ==?

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We're having a discussion about using Equals or == on an int comparison in a LINQ query. We're using EF4.1 Code First. What is better? var query = context.Boodschappen .Where(b => b.BoodschapID == id).FirstOrDefault(); or: var query = context.Boodschappen .Where(b => b.BoodschapID.Equals(id)).FirstOrDefault(); And why ? 回答1: For Linq To Sql, you want neither. Instead, use Object.Equals: .Where(b => Object.Equals(b.BoodschapID, id) Why? Because of a Bug in the SQL Generator if id happens to be a nullable uniqueidentifier. If using b

Expression tree to SQL with EF Core

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We have a column where JSON data is stored as a string. This JSON data is read and converted through materialization to an IDictionary<string, object> . This all works fine until I want to filter on it. The filtering is only applied after getting the data from the database. We will have millions of records so this is not acceptable. My filter is being completely ignored as a WHERE clause by EF Core obviously since probably it has no idea how to parse the MethodCallExpressions. I'm looking for a way to get as close as possible to the SQL

EF 4.1 CF: CREATE DATABASE permission denied in database 'master'

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Entity Framework 4.1 Code First works great with SQLEXPRESS on localhost . However, I'm now ready to connect to a regular SQL 2008 server . I created a new database "NewEfDatabase". Then changed my " ApplicationServices " connectionString in Web.config to point to my new database with integrated security. But then I get this error: " CREATE DATABASE permission denied in database 'master'. " So... a) What permissions does EF 4.1 CF need on said SQL server to do its work? b) Can I setup an empty database on SQL 2008 for EF 4.1 CF, or

EF Code First giving me error Cannot insert explicit value for identity column in table &#039;People&#039; when IDENTITY_INSERT is set to OFF.

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying out Entity Framework 4's Code First (EF CodeFirst 0.8) and am running into a problem with a simple model that has a 1 0..1 relationship, between Person and Profile . Here's how they're defined: public class Person { public int PersonId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public DateTime? DOB { get; set; } public virtual Profile Profile { get; set; } } public class Profile { public int ProfileId { get; set; } public int PersonId { get; set; } public string DisplayName { get; set;

System.Data.Entity.Core.EntityCommandExecutionException Occurred in MVC app Using EF

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am about to create an Application Form with UUID as its unique key (not primary key). I got the error: An exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional information: An error occurred while executing the command definition. See the inner exception for details. Connection String To DB: connectionString = "Data Source=(localdb)\v11.0; Initial Catalog=FormsContext; Integrated Security=True; MultipleActiveResultSets=True

Why does a query generated by Entity Framework take twice as long to run as the same query run directly?

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a simple EF implementation in which I retrieve ~20K records and include two child entities: using ( InsightEntities context = new InsightEntities ()) { return context . Accounts . Include ( x => x . Division ) . Include ( x => x . Division . Company ) . OrderBy ( x => x . ID ) . AsNoTracking () . ToList (); } When I profile the EF call via SQL Profiler, the duration of the SQL command is ~1.2s, even on subsequent calls. But if I copy and paste the same SQL that EF is generating and run it directly through SSMS, the duration

Entity Framework Exception: Ambiguous match found

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I get the error: Ambiguous match found During this code on the .Add var db = new NexusEntities(); db.Reports.Add(mmr); From googling it appears to be an issue if the there are two classes with the same name but in different namespaces. As far as I can tell this is not the case... Is there another reason why this error can happen? Or is there a way to tell which parameter it is finding two of? 回答1: This is a "weakness" in EF. It happens when the same property appears in class / subtype hierarchy. Most likely you have a hidden field. i.e. a

EF4 cross database relationships

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I was wondering if EF4 support cross-databse relationships? For instance: db1 Author Id Name db2 Posts Id Content db1.Author.Id What ideally I need to do to get this relation in my ef4 model? Do you guys have any idea? Thanks 回答1: I've found this entry in Microsoft Connect that answers the question about the support given at this moment by EF (actually it is not supported yet). Also found a thread in Social MSDN about this concern. Other links on Stack Overflow: ADO.Net Entity Framework across multiple databases Entity framework 4 and