Tag: entity-framework

Entity Framework generates many to many tables with weird asian names and properties

I’m currently working in a GIS project, I’m using ASP.NET MVC as platform and Entity Framework (code-first) as ORM. Everything was working just fine until I added the Microsoft.SqlServer.Types package to the solution so I can manipulate geometric data. After building the project, the database was created successfully, but all the many-to-many tables were generated […]

LINQ many-to-many select

I’m currently creating an MVC / AngularJS application using EF database first method. After implementing my database, I realize that I cannot reference many-to-many relations, using the Database-First approach. An example could be Table1 has a many-to-many relation to Table2 through a third table called Table3. Table3 contains two primary keys: the PK of Table1 […]

Problems when using Entity Framework 6 and SQL Server 2016

I was using VS2015 with EntityFramework 6 for mapping my SQL Server 2012 database with database first method. Everything worked fine until upgrade the SQL Server to 2016 version. Now, when I update my database model Visual Studio crash. The only way I can update my EDMX is using SQL2016 with compatibility mode to 2012 […]

Migrating from Entity Framework 6 Code First MSSQL to MySQL

I have worked with EF Code first in MSSQL many times but this is my first time working with it on MySQL. I have been allocated a MySQL database on AWS with a username and password and using MySQL Workbench I can see the database and create/drop tables… Happy Days. I am getting problems with […]

Why edmx file is affecting runtime behavior

I have created an edmx file with a database first approach and have adapted a navigation property name from User.Contact1 to User.DefaultContact in the T4 template like below string foreignKeyName = navigationProperty.RelationshipType.Name; string customizedPropertyName = customizedPropertyNames .Where(x => x.EntityName == entity.Name && foreignKeyName == x.ForeignKeyName) .FirstOrDefault()?.PropertyName; string propertyDefinition = codeStringGenerator.NavigationProperty(navigationProperty, customizedPropertyName); The name is changed […]

Entity Framework auto assign FK to reference Entity during insertion?

Could you please explain for me Why and How EF auto assign FK to reference entity when i insert entities into Database? I got these simple Entities like this: First one is Catalogue public class Catalogue { public int CatalogueId { get; set; } public string Name { get; set; } public ICollection<Page> Pages { […]

Indexing with Entity Framework

Entity Framework seems to always perform, essentially, a “SELECT *” when I access a entity. This makes sense, since the ORM is allowing me to treat the response as an object – all properties should be accessible in the response. In a read-heavy scenario, does this mean that I should tend to prefer a full […]

Is it possible create a copy of Entity Framework context's Instance to make parallel queries

Stack: AngularJs, Web API, Entity Framework, SQL Server. I need to query SQL Server with parallel queries to get the result faster. I am using Web API and can split the query into separate Web API calls, as it creates a new copy of database context for every Web API call, but I am wondering […]

Invalid column name for non-existent column or property

I’m trying to use Entity Framework to save a record to the Address table of our SQL Server database, but upon the call to context.SaveChanges, I get an exception saying “An error occurred while updating the entries. See the inner exception for details.” Upon inspection of the inner exception, there’s a message, “Invalid column name […]

Custom Execution Strategy for Connection Resiliency With Entity Framework 6 and MS-SQL Server

I already developed one application with the EF6 and MS-SQL Server. Everywhere in my application I wrote the code like below where I needed to Insert, Update or delete the data from the table: Code: using (DemoEntities objContext = GetDemoEntities()) { using (TransactionScope objTransaction = new TransactionScope()) { Demo1(objContext); Demo2(objContext); // Commit the changes in […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.