Tag: entity-framework

Entity Framework 6 – Null value in nested query with select

I am facing a problem in EF6. When I execute the query Select it return the value. But when I add Select it returns null. The code is here: The (W) is not null here… var list = db.X.Include(“Y”).Include(“Z.W”) .OrderBy(c => c.Id) .Skip(pageSize * page) .Take(pageSize) .ToList(); Here, The W value is null… var list […]

ASP.NET & SQL Server: won't update but will append/insert

I am using a database-first approach with a custom html helper to get a state of a checkbox using ajax (without using form in the view). I have two tables: Tbl_1 -> Id, state (true or false), name (name of checkbox) Tbl_2 -> Id, user_guid, timestamp, Tbl_1Id (foreign_key) When I do insert operations, it does […]

Get the “sql datatype” of a column created in SQL server using C# and entity framework

I have a table tblDetails consisting of 2 columns Id INT NOT NULL Name VARCHAR(20) By using EntityFramework 6 and C# for my WPF application im fetching the data to display it in the front end. Also I want to get the “sql datatype” of the columns as well. This is the entity model used […]

Entity Framework LINQ query

I would like to know how to change this entity framework linq query. I have tableA with the following columns: project (varchar), code (varchar), assess (integer) the codes data are hierarchical — i.e 10011, 10012, 10013 ..etc are children of code 1001. Another example 123001, 123002, 12300, 12301 are children of code 1230. I want […]

Conflicted transactions

I have this error when my some transactions conflicted. How can i find what is the thansaction in conflict? (Without sql server profiler). I am using snapshot isolation level System.Data.SqlClient.SqlException: Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table ‘dbo.Users’ directly or indirectly in database ‘IUMobileDbRelease’ to update, […]

How to correctly move location of .mdf file and change Connection String's DataDirectory accordingly

Currently my SQL database is on C:\Users\Slaven\KasaMP.mdf I want to move it into my projects directory [maybe “database” folder(?)] and make correct changes on my connectionstring. My goal is to be able to open this project with .mdf file attached on any computer. Current ConnectionString I use is EntityFramework generated and I am not sure […]

c# EntityFramework CodeFirst migration creates a new column for existing one

in my Database models i added a second Column to a table which already had one link to the same table before. My Model before my changes looks as followed: [Table(“RepairProcesses”, Schema = “Data”)] public class RepairProcess : DatabaseBase { [DataMember] [Column(“SerialNumberID”)] public Guid SerialNumberID { get; set; } [ForeignKey(“SerialNumberID”)] public virtual SerialNumber SerialNumber { […]

Entity Framework Bulk Insert/Update with Relationships

I have the scenario where I need to perform DB updates for a large amount of data. There are foreign key relationships that need to be added at the same time and I am getting a list of the foreign objects so I don’t have to hit the database each time to check if they […]

How to map a unary relationship to a separate table in EF?

I am a beginner with EF and MVC, so, I have been using the Database first approach. I am facing a problem which is, I have in my database a table called Subjects, and another one called Prerequisites. The Idea is that each subject is supposed to have one or more prerequisite. When I created […]

Error no mapping column in Entity 6 DB first design

I have a legacy mvc application which I cannot rewrite. There’s a stored procedure which all the returns column names of table A except for ID. (Note, it actually does not select from table A, but just happens to return the same column names). I wish to call the stored procedure (via SQL query), and […]

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