entity-framework-6

The underlying provider failed on Open and other exceptions with local DbContext variables

守給你的承諾、 提交于 2020-08-20 10:33:19
问题 We have a static DbContext that we use throughout our project. Here is the get method: public static istanbulEntities DbContext { get { string ocKey = "ocm_" + HttpContext.Current.GetHashCode().ToString("x"); if (!HttpContext.Current.Items.Contains(ocKey)) HttpContext.Current.Items.Add(ocKey, new istanbulEntities()); return HttpContext.Current.Items[ocKey] as istanbulEntities; } } We were having exceptions with some of the routine tasks that we have in Global.asax, and these problems were:

Disable publish of EF configuration files to bin folder

可紊 提交于 2020-08-10 23:48:08
问题 I never came across the needs until now to do something about publishing of the XML configuration files that come with EntityFramework referenced projects. Those configuration files contain connection strings that are also within the Web.config of the start-up project - which we do not want right now. I understand that those configuration files are mandatory for EF and models while they are within VS, but since the connection string is taken from the Web.config and not Models.dll.config is

Disable publish of EF configuration files to bin folder

☆樱花仙子☆ 提交于 2020-08-10 23:47:31
问题 I never came across the needs until now to do something about publishing of the XML configuration files that come with EntityFramework referenced projects. Those configuration files contain connection strings that are also within the Web.config of the start-up project - which we do not want right now. I understand that those configuration files are mandatory for EF and models while they are within VS, but since the connection string is taken from the Web.config and not Models.dll.config is

Why am I receiving an EntitySqlException when executing a LINQ to Entities query that uses a custom DB Function?

痞子三分冷 提交于 2020-08-10 18:54:26
问题 As you may already know, when using LINQ to Entities with EF6 you can not use Int.TryParse or anything really trying to convert/cast a string to an int. I've created a custom function convention below to mitigate this: Public Class CustomFunctionConvention Implements IConceptualModelConvention(Of EdmModel) Public Sub Apply(item As EdmModel, model As DbModel) Implements IConceptualModelConvention(Of EdmModel).Apply Dim functionParseInt = New EdmFunctionPayload With { .CommandText = String

Query PostgreSQL with Npgsql and Entity Framework using unaccent

怎甘沉沦 提交于 2020-07-06 20:29:32
问题 Is possible to use Npgsql and Entity Framework 6 for query PostgreSQL ignoring accents? In play SQL it's possible to use the unaccent extension and could be indexed with a index also based in unaccent: select * from users where unaccent(name) = unaccent('João') In previous projects using MySql I could solve this problem just using a collation accent insensitive like utf8_swedish_ci but PostgreSQL lacks this kind of solution as far as I know. 回答1: If you use the Codefirst approach, you should

Does Entity Framework 6.1 support an XML data type natively?

我与影子孤独终老i 提交于 2020-07-04 10:08:54
问题 Some RDBMSs (including SQL Server) support XML columns. I'd prefer not mapping such a column to the string data type. Does Entity Framework 6.1 support XML natively in any way? More specifically, can I map an xml column to one of the XML data types of .NET (such as XElement or XmlElement )? Does Entity Framework support XQuery that is integrated into normal LINQ queries and is translated to SQL queries? 回答1: No, only mapping it to string and then having to stream it back in to an XML document

Decoupling ASP.NET Identity from the Core Domain Models - Onion Architecture

|▌冷眼眸甩不掉的悲伤 提交于 2020-07-04 06:29:11
问题 I am using this sample project (https://github.com/imranbaloch/ASPNETIdentityWithOnion) as my application architecture, in this sample the core is completly decoplied from the infrastrure including the identity framework. In this sample the author has used the adapter pattern to decouple core identity classes (IdentityUser, IdentityRole ... ) and provide classes like them in the Core layer. Now the issue in this sample project is that the Domain model (Product, Images) are not linked with the

Is this a bug in JSON.NET or Entity Framework or am I doing something wrong while trying to serialize a list of Exceptions with JSON.NET?

大城市里の小女人 提交于 2020-06-23 08:31:47
问题 Got this error when trying to serialize a set of errors: "ISerializable type 'System.Data.Entity.Infrastructure.DbUpdateConcurrencyException' does not have a valid constructor. To correctly implement ISerializable a constructor that takes SerializationInfo and StreamingContext parameters should be present." The constructor is in fact present in the base classes, but it is a protected member. Someone asked to see the JSON: { "$type": "System.Data.Entity.Infrastructure