entity-framework-6

Entity Framework 6, .NET Framework 4.0 and SaveChangesAsync

荒凉一梦 提交于 2019-12-11 13:48:34
问题 I am developing on VS2012 , targeting .NET Framework 4.0 and using EF6 . I have installed Nuget packages from Microsoft. <package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" /> <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" /> <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" /> I'd like to save changes to database asynchroniously. I found there is Await available but I cannot find SaveChangesAsync . What do I need to do to

How do I update a password that's in a different format from the defined model? I'm getting DbEntityValidationException

我们两清 提交于 2019-12-11 13:42:22
问题 The Problem I have a pre-defined [StringLength()] and [RegularExpression()] constraint on my Code-First Model. The [StringLength()] requirement is 8-16 characters The [RegularExpression()] constraint for the password is in a different format from the encrypted password. The password is encrypted before being shoved into the database. The encrypted password is 70 characters in length, which is higher than the 8-16 character limit defined in the Model. I am required to use e.Encrypt() , meaning

It is possible to query a NotMapped property?

拥有回忆 提交于 2019-12-11 13:08:51
问题 i'm working with EF6 code first, and i used this answer to map a List<stirng> in my entitie. This is my class [Key] public string SubRubro { get; set; } [Column] private string SubrubrosAbarcados { get { return ListaEspecifica == null || !ListaEspecifica.Any() ? null : JsonConvert.SerializeObject(ListaEspecifica); } set { if (string.IsNullOrWhiteSpace(value)) ListaEspecifica.Clear(); else ListaEspecifica = JsonConvert.DeserializeObject<List<string>>(value); } } [NotMapped] public List<string>

Adding Expression argument as property in LINQ to Entities

不羁的心 提交于 2019-12-11 13:07:34
问题 Using EF6, how would I bind a given Expression<Func<Row, string>> argument to an existing select expression, without having to rewrite every property binding using expression trees? public IEnumerable<RowModel> GetRowModels(Expression<Func<Row, string>> textExpr) { return from row in MyDatabaseContext.MyTable select new RowModel { RowID = row.ID, CreatedDate = row.CreatedDate, AnotherProperty = row.AnotherProperty, Text = textExpr, // how do I bind this expression? Value = row.OtherStuff

Does the order of Include()s when filtering have an impact on performance?

无人久伴 提交于 2019-12-11 13:07:31
问题 This works fine, and I assume it loads all the entities with all the Foo and Bar children, then filters the results based on Foo 's value: var baz = "sillystring"; context.Entities .Include(e => e.Foo) .Include(e => e.Bar) .Where(e.Foo == baz) .Select(e.Bar) .ToList(); So if that's the case, is this a helpful optimization where the filtering is done first and then Bar children are included only for a subset of entities? var baz = "sillystring"; context.Entities .Include(e => e.Foo) .Where(e

how to deploy npgsql on Raspberry pi 2 (Mono 4 + ARM proc)?

廉价感情. 提交于 2019-12-11 13:03:11
问题 I use Visual studio 2013 (Windows) to build a small .NET 4.5 application using Npgsql and Entity Framework 6. On windows it just works fine. But on Raspbian, the app crash saying it cannot find npgsql provider. Unhandled Exception: System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider 'Npgsql'. at System.Data.Common.DbProviderFactories.GetFactory (System.String providerInvariantName) [0x00000] in <filename unknown>:0 [...] On my

Difference between updating an entity by using a foreign key and using the navigation properties In Entity Framework

浪尽此生 提交于 2019-12-11 12:53:29
问题 -I Want to know the Difference between updating an entity by using foreign key and using the navigation properties in Entity Framework. -Is there a way to update a complex object with only one call to the database? 回答1: Using the Foreign key to update an entity is preferable over the navigation property, simple because you won't have to deal with the state of the entities. The most common problem with updating entities using navigation properties is getting duplicates records when you

Why is IDbCommandTreeInterceptor being skipped on second query?

半城伤御伤魂 提交于 2019-12-11 12:49:22
问题 Using entity framework I have implemented soft delete & data level restriction with IDbCommandTreeInterceptor. For the first query using the context, the interceptor gets hit. But trying again (refreshing browser), the interceptor is skipped. I have checked whether data is being cached by changing some data using SQL server management studio. The changes are reflected but the interceptor is still skipped. What could possibly be causing for this to happen? 回答1: according to the sources

Accesses DB2 with entity framework 6 on visual studio 2015

时间秒杀一切 提交于 2019-12-11 12:36:25
问题 I'm trying to access DB2 V10 over z/OS via visual studio 2015 and entity framework 6. After some research i found some promising article - http://www.ibm.com/developerworks/data/library/techarticle/dm-0903linqentity/ However the example used is for 2010 and the same Add-in is not getting installed for 2015. Is there any better way of doing this with the combination of VS 2015 + EF6? Am i missing anything? Note : I don't have the luxury of using third part software's to accomplish the task. I

Entity Framework Table Per Hierarchy Inserting Multiple Id Columns

点点圈 提交于 2019-12-11 12:36:16
问题 I have seriously spent two work days trying to a TPH setup from Database First to Code first. The Error I get is Something like "Invalid Column Name Entity_EntityId/ Entity_Entity_Id1" I've drawn up a very basic reproduction of the issue like so: internal class Program { private static void Main(string[] args) { using (var context = new Context()) { var baseClass = new Base {Name = "Test"}; context.BaseClasses.Add(baseClass); context.SaveChanges(); var baseClasses = context.BaseClasses.ToList