Questions tagged [entity-framework]

For questions relating to Microsoft's object-relational mapper.

Filter by
Sorted by
Tagged with
-3
votes
0answers
30 views

How to store version of a row where columns could change in the future?

I have a form(table) with several sections(one-to-many) that will get stored in a SQL database. I currently need to create versions of the form record(row) once it gets to a certain status or some ...
1
vote
1answer
61 views

There is already an object named PK_MyPrimaryKey in the database ( primary index on temp table)

Simplified code var sql = @" create table #Temp( int Id NOT NULL CONSTRAINT [PK_TempId] PRIMARY KEY (Id) ) insert into #temp(id) select (...
0
votes
0answers
17 views

If there is mandatory participation between 2 entities in an ERD, does this mean neither of them are strong entities?

Say I have entity A with primary key "key_A" and entity B with primary key "key_B”. I also have that key_A is a foreign key in entity B. My business rules state that every instance of A ...
3
votes
2answers
268 views

SQL Server - Automatically full backup for new databases which are auto-created with EntityFramework-Migrations

I have an ASP.NET MVC Application with a Multi-Tenant architecture (using SQL-Server). I'm using EntityFramework DB-Migrations which automatically generates a database per customer. In SQL-Server I ...
0
votes
1answer
35 views

Is there a way to tell if a GUID column contains sequential or traditional / random GUID's?

Have a table that is populated by Entity Framework 3.1.1 code. The table contains a clustered index / primary key on ID which is defined as of type GUID with no default value. Is there a way in SQL ...
0
votes
0answers
35 views

Database Design - Can't figure out entity relationships for web application backend

Background I'm working on a personal project to replace a scheduling system at work. This is outside my regular duties and I'm hoping to be able to present a replacement web application to my ...
0
votes
2answers
198 views

Update via C# EF Core or SQL

Our work involves updating products, we have a large table of products, and the prices and other pertinent information gets updated hourly. Let’s say it’s an amazon store, and we are talking of amazon ...
0
votes
0answers
59 views

ADO.NET entity data model wizard crashes when creating a Postgresql data model

I am having trouble creating an ado.net data model from an existing Postgres database. I have used Npgsql and connected successfully but the wizard crashes without any error when I try to add a new ...
1
vote
1answer
62 views

Multiple roundtrips vs cross joins

I have a feeling the answer is "it depends on...", but I'm wondering if there's a concrete answer. In Entity Framework, you build a query using C# code, and the framework converts to SQL and ...
2
votes
1answer
277 views

Troubleshooting spid suspended ASYNC_NETWORK_IO

Recently we moved our database to a new server The old server was running Microsoft SQL Server 2017 (RTM-CU16) (KB4508218) - 14.0.3223.3 (X64) Jul 12 2019 17:43:08 Copyright (C) 2017 Microsoft ...
0
votes
0answers
106 views

Use the following business rules to create a Crow’s Foot ERD

Is there any mistake in the ERD???? it looks weird.
0
votes
0answers
34 views

How to compare EF core code-first database with existing Azure Sql Server database

we have multi-tenants databases and we have special stored procedure to compare the structure of the tenents after each release. Now, we are moving to Azure SQL Server and the stored procedure is not ...
5
votes
1answer
349 views

SQL Server - Very high disk activity after running query?

I'm running SQL Server Express 12.0.4100 on an AWS instance with 16 cores and 64 GB of RAM with a 3TB and 9000 IOPS EBS attached. This has been running for 2 years perfectly with no issues until this ...
0
votes
1answer
530 views

MSSQL Join between big and empty tables

I've got an issue with estimated cost and join predicate : SELECT c.Id FROM Table_A a LEFT JOIN Table_B b ON b.Id_A = a.Id LEFT JOIN Table_C c ON c.Id_B = b.Id WHERE a.Id = 2500 OPTION (RECOMPILE) ...
1
vote
1answer
68 views

Entity Relationship Diagram - Entity depending on attribute

I have an ER-Diagram containing the entity employees. When employees have high skills they may supervise lower skilled employees. How can I model that in an ER-Diagram? My initial approach of was to ...
-2
votes
2answers
64 views

INSTEAD OF INSERT does not display changes

This is my table: CREATE TABLE [MyTable] ( [GroupId] INT NOT NULL, [ItemId] INT NOT NULL, [Data] INT NOT NULL, PRIMARY KEY CLUSTERED ([GroupId], [...
0
votes
1answer
2k views

Entity Framework 6: How can I add new column to existing table and at the same time update view (add column) in same migration file [closed]

Example in the EF6 migration file Up method. I wish to add a new column B in existing table Country. Sql("ALTER TABLE [dbo].[Country] ADD [B] INT DEFAULT((0)) NOT NULL;") Then I will need to ...
0
votes
0answers
167 views

Database design for multilingual tags

I'm looking for a simple database design for tags, where the tag-label can be translated (multilingual). I'm currently looking at Toxi, which is a very simple and clean way of creating a tagging ...
2
votes
0answers
121 views

Code First Migrations with an existing database - How do I make sure migration won't affect the existing data?

I am referring https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/existing-database I am using Entity frame work Code First Migrations for an existing database. I get the below ...
0
votes
2answers
759 views

INNER JOIN is extremly slow on some rows and create temp table

The MySQL query SELECT `p`.*, `p.Author`.* FROM `post` AS `p` INNER JOIN `user` AS `p.Author` ON `p`.`userid` = `p.Author`.`userid` WHERE ( ( `p`.`threadid` = 29780 ) AND ( `...
3
votes
2answers
198 views

SQL Server one-to-many and index fragmentation

I'm currently writing code to update an entities child collection (one-to-many relationship), and while thinking about how to write code to determine which entities have been added/removed/modified, I ...
2
votes
2answers
193 views

Performance problem with big query on first run

I'm having a problem with a query usually being so slow on first time run that it times out and then executing in under a second once it's loaded into cache. The query looks something like this exec ...
3
votes
1answer
2k views

Can Entity Framework access In Memory OLTP Tables?

Are there any restrictions with having Entity Framework access In Memory OLTP Tables? Or is this not possible?
3
votes
1answer
124 views

Delete Joined to Derived Table Causes Index Scan and Table Spool

Our application uses a popular 3rd-party extension to Entity Framework that allows for valuable things that native Entity Framework is not capable of or designed to do, like bulk deletes and updates. ...
3
votes
1answer
6k views

Passing an array of integers as a parameter of an (inline) user defined function (SQL Server)

I have TBV function . Like this ALTER FUNCTION [dbo].[fn_Functiont] ( @accessibleIds ListAccesableIds READONLY ) RETURNS TABLE AS RETURN ( SELECT d.*, b.Name AS Name, ps.Name AS ...
1
vote
0answers
867 views

Keeping MySql connections alive

I'm running a Windows service, which connects to a MySql database via Entity Framework. Every 10 seconds it issues a query to the database to see if any new records have been added. If it finds any, ...
5
votes
1answer
186 views

Empty result takes longer with all columns included

I'm executing a query every 1 second and most of the time it returns no results (SQL generated by Entity Framework): SELECT TOP (5) [Extent1].[ID] AS [ID], ***30 more columns*** FROM ...
0
votes
0answers
477 views

SQL Server bitfield/flags in int indexing

In a schema, an int is used as a bitfield, one of those bits is used in a frequently called SQL query (a bit marking entries to be new for processing). The query (entity framework generated, got it ...
1
vote
1answer
264 views

Inserts via Entity Framework on server take about double the time than locally

I'm inserting lots of data into SQL Server with many of them having foreign key dependencies. Meaning if I insert 1 row in my Person table, I'm also inserting 1 row in 8 other related tables. This ...
1
vote
2answers
2k views

SQL Server Order SELECT List with condition

I want order the select list with condition. For example; I have t1 table and it has 3 columns and 6 rows Table t1: +----+---+---+ | id | x | y | +----+---+---+ | 1 | a | 1 | | 2 | b | 3 | | 3 |...
0
votes
1answer
393 views

My first database schema design

I'm new to programming and databases and working on my first application using .Net, Entity (for SQL Server) and Identity. My application will allow users to create html pages for online courses. ...
1
vote
1answer
661 views

sp_executesql processes uniqueidentifier-param with EntityCommandExecutionException but still acts like expected

I use a Azure DB(MS-Sql) and administrate the DB with Management Studio for SQL Server 2016. My Application is a simple C#/WPF-Application. So here we go, this is my SProc: ALTER PROCEDURE [dbo]....
2
votes
1answer
136 views

Entity Framework Coupling with Database

I am new to EF and Database Design. I have been studying about using Repository Pattern and Unit of Work a lot, and I have seen a lot of queries made with LINQ. But I have one question. If, in ...
3
votes
3answers
4k views

Visual Studio database project and Enity Framework code-first

At work we are developing our latest module in C# Entity framework code-first approach. I have been given the role of developing databases from the DBContexts from within the project/s. I generated ...
2
votes
1answer
188 views

DB Design Challenge

I don't have much experience designing databases and I have this case that I stumbled upon where I hope there is a definite answer in terms of DB design methodologies. I also have to mention that I am ...
-1
votes
2answers
296 views

Custom Paging in Stored Procedure (Optimizing the Performance)

I have a stored procedure that is working perfectly but the issue is performance. There are so many joins in this stored procedure and unions... So after having the query executed, i need to send only ...
1
vote
1answer
408 views

Unnecessary Hash Match in Query

I've just migrated a database from SQLExpress (Entity, Database First) to Azure (Entity, Code First) and some of the indexes are missing because they werent migrated (on purpose, I think a lot of them ...
0
votes
1answer
256 views

Inheritance and performance in database [closed]

I have 3 table linked by an "inheritance" with Entity Framework. Sadly, I have poor performance with those query because I can't make any good index. Here is the tables : CREATE TABLE [dbo].[...
0
votes
1answer
1k views

Create a User and Password for ADO.net and SQL SERVER Authentication

I am trying to create a sample application in asp .net mvc with sql server authentication. I want to create a user with password in sql server so that i can provide it in connection string in asp ....
5
votes
2answers
3k views

What's the best practice of inserting a collection of data into a SQL Server database

I am using C#, Entity Framework. SQL Server for the development. I have a method which has two parameters (int ID, List<String> _listobj). For each ID, there is a list of obj. All of these IDs ...
3
votes
1answer
497 views

Data read from linked server returns different data-type on production server

I have a SQL Server grabbing data from a linked Oracle server inside a SP. On my development server, EF6 insists the SP is returning a double datatype for one of the columns, but in prod, it insists ...
0
votes
1answer
346 views

The same set of columns for two tables

I have the following db schemas: Comments table and Posts table ( has FK to Comments table) : As you can see, there is a set of the same columns for both tables. Is it bad design? If yes, how can ...
3
votes
1answer
87 views

Complex dto based result sets with EF and MS SQL server

ok lets say I have a collection of these ... public class ReferenceLookup { public string InvoiceNumber { get; set; } public CompanyReference Buyer { get; set; } public CompanyReference ...
3
votes
1answer
5k views

Entity Framework SaveChanges fails due to a trigger

Trying to implement Entity Framework for an existing database (SQL Server 2012). I have a VB application running and trying to convert it to the EF based Web API. When I insert data into the table ...
2
votes
1answer
353 views

best way to add Entity id & entity types in database

we are doing shopping site with mysql with eav model to store values. in below image , 2 types of entity types are there under products_information table : 1) Mobile 2) T-shirts I wanted to know in ...
3
votes
1answer
3k views

Handle concurrency on sql server for a booking system

I've been banging my head against the wall trying to solve this problem and I couldn't come up with a solution that absolutely guarantees two users can't book an appointment for the same time. The ...
0
votes
2answers
3k views

Why shouldn't I increase SQL Server's timeout globally everywhere?

I have an application in which some reports time out before getting data. We started increasing timeout througout our code in different places, and as our database is growing bigger and bigger, we see ...
0
votes
1answer
35 views

Remove some auto created indices from Entity Framework?

I'm using Microsoft's Entity Framework. It automatically creates indices for every foreign key, but in many cases, I can see from the index stats that these are never used for reading - they are only ...
1
vote
1answer
3k views

Very slow insert performance on large table (EF) [closed]

One of our systems has a table that receives around 20k inserts per day - it currently contains ~10m rows. We've just pushed out a system upgrade and I'm intermittently getting some shockingly slow ...
0
votes
0answers
529 views

Help with SSIS Framework- Resolve Referrences in Data Flow

LineageString and StageKey are both unmapped. SSIS is giving me an error between the OLE DB Source and the Add metadata. Add Metadata.Inputs[Derived Column Input].Columns[LineageString] has lineage ...