Tag: entity-framework

Which way is correct to connect to SQL Server for transaction

Which way is more correct to delete entity? Correct means: for a lot of rows, we should use way that is more trust-able and close transaction after end of work First attempt: public class UserRepository : IDisposable { private DomainModels.BotEntities _dbDnt = null; public UserRepository() { _dbDnt = new DomainModels.IraniBotEntities(); } public bool Delete(int id, […]

Retrieve varbinary value as BASE64 in MSSQL

I’m looking for a way for retrieving Entity Data Model (EDM) from __MigrationHistory table using only T-SQL (so anyone, using Microsoft SQL Server Management Studio only, could do the same). I want to have a valid BASE64 string value. I don’t want to fully decompress it to EDMX. I don’t want to get it from […]

CREATE DATABASE permission denied in database 'master' when Integrated Security=false – Why try to create a database that already exists?

I have an ASP.net MVC app connecting to (localdb)\v11.0 SQL Server database with a connection string using “Integrated Security” – works fine. Now I want to connect to the same db with a User ID & PW. I created the login & user: user100, gave it db_owner permission. I can open the db with that […]

Issues in LINQ to SQL with String Contains Escape seqence of Backspace – C#

I have a table in SQL Serve which contains the following model and values: public class Employee { public int EmpId { get; set; } public string Name { get; set; } } It contains the following values EmpId Name ______________________________ 1 A 2 B 3 C C# code to get the records using .Contains(“A\b”) […]

Entity Framework creates a table I don't want

I am using Entity Framework Code First approach to have Data Access in my application. I have a table Web_Documents and a table Web_Profils and a relation table Web_Profil_joint_Documents, all of which I have made POCOs for. My problem is when I added a migration, Entity Framework created an extra relation’s table.Now in my context […]

Is it better to use one or many contexts

We have an application that has 3 contexts for connecting to 3 SQL Server databases, under the same server. Our DBAs are arguing that these three connections are being costly for the server. My question is: is it true? Are three connections more costly than one? How can I measure it? What is the best […]

Lambda query translate .count as select rows (EF6 code first)

I have 2 simple tables. Post is the master and has n votes. I want to return posts with their vote count. This is my code: db.posts.Select(p=> new PostlDto{Title= p.Title, VoteCount= p.Votes.Count}) It is ok that I have 1 call to get posts and several calls to get counts. but the problem is that each […]

Why would C# linq to sql return the same exact record

So I have this Entity Framework query in which the SELECT statement which i can copy and run in sql server ctx.MainOrders returns 2 very different records. However when i run this LINQ query with .AsEnumerable() and .Select(z => new MainOrder() i’m getting the EXACT SAME record twice! :/ This class is a POCO public […]

MVC 4 SimpleMembership Model first

I have researched for the last couple days on Stack and other coding sites and cant seem to find a fix for my problem. My goal is to configure simplemembership with my own database.(yes i have done a search and none of them answer my question) I’m using visual studio 2013 and entity framework 4 […]

Why is an index created more than one time in SQL via Entity Framework

I have written a service, which imports every night more than 960.000 rows to a SQL Database. This data will be used for other operations few hours later. The application is a .Net application, with Entity Framework on it. Import is being made with EntityFramework BulkExtensions. After 3-4 Imports, I receive TimeoutExceptions. Some experts from […]

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