S
S
Sergey2019-05-11 18:00:04
SQL
Sergey, 2019-05-11 18:00:04

Why is the entity framework requesting a non-existent column?

There is a class

public partial class Users
    {
        public int Id { get; set; }
        public string Email { get; set; }
        public string Surname { get; set; }
        public string Name { get; set; }
        public string Post { get; set; }
        public string ServerRole { get; set; }
    }

And there is a MSSQL database. When calling a Users instance from it, an error occurs: "SqlException: Invalid column name "RequestsId"
I don't have such a field not only in the database, but also in the project. I even searched for CTRL + SHIFT + F, I can't find such a word.
Server Profiler of course shows:
exec sp_executesql N'SELECT [u].[ID], [u].[Email], [u].[Name], [u].[Post], [u].[RequestsId], [u].[Server_role], [u].[Surname]
FROM [dbo].[Users] AS [u]
WHERE [u].[Name] = @__Username_0',N'@__Username_0 nvarchar(30)',@__Username_0=N'admin'

Actually, where did the entity framework get it, RequestsId, and how to persuade it not to take it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
asdz, 2019-05-14
@asdz

Your class is marked as partial, remove it.

R
Roman Mirilaczvili, 2019-05-11
@2ord

The .edmx file must be present, so.
If found there, then you need to update the models.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question