All Questions
Tagged with crud entity-framework
105 questions
0
votes
0
answers
66
views
How to do CREATE for tables with foreign key in ASP.NET C#
{
"FacilityID":"18c9aebb-0874-4fc2-900e-48f6b192797f",
"FacilityRoomNumber":102,
"FacilityPurpose":"DSFDSF",
"LabTypeID":"...
0
votes
1
answer
45
views
Operator '==' cannot be applied to operands of type int and string
public void Delete()
{
try
{
string m = Request.QueryString["m"];
Chef tbl = db.chefs.SingleorDefault(x => x.ChefId == m);
}
catch()
{ }
}
Doing CRUD ...
0
votes
1
answer
73
views
ASP.NET 6 input validation: unique column on create - but validation problem on update
I have a table with key Id, and have a unique column (Name). When creating a new row, the Name must be unique. I created a custom validator.
public class UniqueNameValidationAttribute : ...
0
votes
2
answers
510
views
Best way to do large CRUD operations
I'm working on an application where I need to get large amount of data from a database, do some data manipulation and then insert the data in another database.
However, I am struggling to find the ...
0
votes
0
answers
27
views
How to make an insert form and a table displaying data from database in a single view in MVC5 using Entity Framework
List and create in same view in asp.net mvc5 with EF
I need to display the data in grid after submitted users details:
simply I have
Form: name , city @Create
Table @Index
0
votes
1
answer
553
views
How do I prevent a duplicate entry for a Create/Edit Functionality in ASP.NET Core w/ EF?
I am trying to prevent a user from creating a form with a FirstName, LastName, and DOB that match an entry in the database and editing a form to match an existing entry. If you could also lead me to ...
-3
votes
2
answers
1k
views
Entity Framework : boolean value is true
How can I set the default value of a boolean to false in Entity Framework in .NET Core.
Thank you
public class CategoryVM
{
public CategoryVM()
{
isOpen = false;
Products = ...
-1
votes
1
answer
352
views
ASP.NET MVC crud operation with Entity Framework and AngulaJs and Web API
I have to build a website in ASP.NET MVC using AngularJs, Entity Framework and Web API.
Please help to do this crud operation in this, please guide me.
To perform crud operations..
0
votes
0
answers
23
views
MVC Validation - Issue checking DB records for matching values before posting
Hi everyone I cant seem to figure out how to check a record before creating a new post in MVC
When a user creates a "SuperMember" I want it to check IF that "Character" has already ...
0
votes
1
answer
880
views
Id vs Object as parameters in Delete HTTP Post. Which is better?
I am trying to implement a simple CRUD using ASP.net Core as a beginner. My issue is with an HTTP post called DeletePlayer(). Please consider my code below:
Model:
public class Player
{
public int ...
1
vote
1
answer
276
views
Create login and user for Entity Framework with limited permissions
I dont want to give sa or windows auth account to Entity Framework. What i want is a limited login and user for CRUD operations and whatever Entity Framework needs else. Thanks for any help.
0
votes
0
answers
216
views
How to get data get from multiple tables and update using EF
I have successfully inserted data into two tables which are working fine. Now I am just stuck as to how I can get the details from both tables and update them. After inserting, I want to query both ...
0
votes
1
answer
610
views
Issue with Entity Framework, the table or view does not have a primary key
I have a small crud app in ASP.NET MVC using Entity Framework, everything works fine, only that I was asked to use a view to add to the crud. In any case this view does not have a primary key and when ...
0
votes
0
answers
319
views
How do you create a MVC view for navigation properties (one to many, many to many)
I have two ASP.NET MVC EF entities sharing an association:
When I am editing or creating the User, I'd like to be able to attach one or more UserRoles. So, my User Create view looks like this:
@model ...
0
votes
1
answer
154
views
Error C1061 "... does not contain a definition for 'TextBox_TextChanged' ......." update SQL Server database with Entity Framework
I have a database table Doctor which contains columns code_doctor (varchar), name (varchar), gender (varchar), salary (int). I want to implement CRUD in this database, using Entity Framework. But, ...
0
votes
0
answers
57
views
Database/Models structure
I am new in web development and trying to learn on my small project but got stuck with the database/model structure. Web application is for buying/selling new/second hand products(Cars, Real estate, ...
2
votes
0
answers
248
views
C# ERROR CS7036 Entity Framework and stored procedures
I am trying to do a crud with Entity Framework and stored procedures in SQL Server, I have difficulties with the save method and the modify method.
I get the following error when I try to assign my ...
62
votes
26
answers
152k
views
An error occurred while accessing the Microsoft.Extensions.Hosting services when do first migrations
I don't understand what wrong.
I tried to make a simple crud in .net core mvc with a very simple model which has few fields.
These are my models:
public class Employee
{
[Key] public ...
0
votes
1
answer
2k
views
Use Different CRUD Submit Button in Same View in ASP.NET Core with Entity Framework Core
I manage the read, update and delete process from a database through Entity Framework Core via three different buttons in a Razor page structure on ASP.NET Core.
I'm sending a class to a .cshtml page ...
0
votes
1
answer
71
views
System.InvalidOperationException while trying paging
When I try Index view is giving me this error
Can anybody tell me what to do about it
"The model item passed into the dictionary is of type
'System.Collections.Generic.List1[MvcCRUDSearching....
1
vote
0
answers
273
views
How to communicate model attributes and/or data annotation to a vue.js
I'm using DotNet, Entity framework and Vue.js.
The missing puzzle piece is this: I'd like my Vue.js to be able to read/know the attributes I've applied to/in my models.
Let's suppose I have models ...
0
votes
1
answer
370
views
Example of CRUD operations on classes with many-to-many relationship | Entity Framework Core
Suppose I have the following class with Many-To-Many relationship to itself:
public class A
{
public int Id { get; set; }
public string Title { get; set; }
public ICollection<A> ...
0
votes
1
answer
45
views
The advice on the simplification of the functions
I have an entity Contracts like this:
public partial class Contracts
{
public Contracts()
{
ListKindWorks = new HashSet<ListKindWorks>();
ListSubjects = new HashSet<...
0
votes
0
answers
134
views
Ado.net Entity Data model - Crud issues
Im new to ADO.net Entity Data Model.
I need some advice as I'm getting confused trailing round the web looking for answers. So I have an existing MS SQL DB with 2.5m+ records. The standard SQL data ...
0
votes
0
answers
24
views
How to send LIST while i'm doing "Modified" in mvc
Firstly one i have a Edit method in controller and 3 values are coming to my "questionList" parameter from view.
I want to use this method for "Modified" operation with this list which has 3 values ...
0
votes
1
answer
113
views
Best way to handle complex entities (relational) with Generic CRUD functions
I have tried using this generic functions to insert-update Entities but I always thought that maybe I am doing this totally wrong so therefore I would like to have your opinions/suggestions.
These ...
1
vote
1
answer
1k
views
What's the differences between EntityState.Added and Add()?
I'm recently using this to add entity EF to my DB:
ctx.Entry(payment).State = payments.ID == 0 ? EntityState.Added : EntityState.Modified;
Instead of the common:
ctx.Payments.Add(payments);
The ...
0
votes
1
answer
36
views
EF Entry doesn't take care about deleted items?
I'm doing some CRUD operations from my model (ASP.NET MVC) to my Database, using Entity Framework. Here how I Add/Update my entities, within the Action of my Controller, mapping the ViewModel to Model:...
0
votes
1
answer
142
views
How to create a dependent dropdown in MVC c#
I have created a single dropdown using ViewBag function . I want to pass id of selected option(in dropdown) in such that the dropdown populates which corresponds to that id .
dropdown 1 being States ...
0
votes
1
answer
1k
views
Updating a single value in a database
I'm trying to update a value in an existing row of a database but I can't seem to get the changes to stick. the code in my controller currently looks like this:
[HttpPost]
public ...
2
votes
1
answer
2k
views
Many To Many Relationships in EF Core
I have two entities with many to many relationships in my .NET Core project:
Book:
public class Book
{
[Key]
public int BookId { get; set; }
public string Name { get; set; }
public ...
0
votes
1
answer
84
views
How to load an object from the database (Entity Framework)
For this simple User class
public partial class Users
{
public long Id { get; set; }
public string User { get; set; }
public string Password { get; set; }
}
I have ...
1
vote
1
answer
34
views
Entity Framework auto-determination whether to update or create entity
I'm new to EF.
After searching hours on the internet I want to ask my question in here.
Is there really no built-in mechanism in EF to determine, whether to update or create an entity?
Suppose I ...
0
votes
0
answers
161
views
ASP.Net MVC - Many to Many CRUD
I'm new in ASP.NET MVC and I'm having a few problems with Many to Many CRUD.
I need to create a N:N between two tables and create an entry before the two types are created.
I have the following code:
...
0
votes
1
answer
463
views
ASP.NET MVC when remove shopping cart from database?
I made a shopping cart through this example.
The question is, when the user adds the products to the cart and stores it in the database, but does not log in or register and leave the site, then when ...
-1
votes
3
answers
2k
views
SYMFONY -- Generate CRUD: entity doesn't exist but already created
I'm having trouble to generate a CRUD for my entity.
[[RuntimeException]
Entity "Post" does not exist in the "PlatypusBundle" bundle. You may have mistyped the bundle name or maybe the entity doesn'...
2
votes
3
answers
432
views
Implementing MVC design pattern with Repositories and Mapping, C#
I have a problem with implementing the CRUD operations by using repositories, view models, and mapping in my ASP.Net MVC project. The "details"(read the information about one object) and "index"(read ...
3
votes
1
answer
153
views
Basic F# / Entity Framework / Generic Functions
I'm a complete beginner when it comes to development, so apologies in advance for my poor grasp of the terminology here...
I'm trying to create a number of very simple unrelated tables in a SQL ...
0
votes
2
answers
1k
views
Deleting records from nested tables MVC 5
I am having trouble with deleting from 3 nested tables that I have.
When I try and delete a record from the first table, it gives me an error
System.Data.SqlClient.SqlException: The DELETE ...
0
votes
1
answer
1k
views
Why is my (id == null) returning null on my update method in Entity Framework MVC?
Ok, so I've posted a few things that I'm doing with this project. I'm still learning. Anyway, my controller when it is calling the view for my update method. I'm getting null for the id parameter. I ...
1
vote
1
answer
640
views
Entity Framework 6 Updating a record manually
I am using EF 6 with WPF. Since I have to work with lots of DataSets, I have to use AsNoTracking() with the queries. Thus, updating any of the entries is now a responsibility of the ViewModel. I am ...
1
vote
4
answers
558
views
How can I store the current time to my database when create button clicked?
I am making a CRUD operations in MVC. I am also using Entity Framework.I am showing the user only 12 value of table(there is also currenttime(createDateTime) value which user cant see till they create)...
0
votes
1
answer
95
views
Update mutiple records in database MVC 5 EF
Good evening,
Now I'll describe my situation:
Here is my Model:
[Table("Items")]
public class Item
{
[Key]
public string Id { get; set; }
public DateTime Generated { get; set; }
...
1
vote
2
answers
4k
views
How to use RemoveRange with 1-query-approach Entity Framework 6
I look for a way of executing RemoveRange() with 1-query-approach. With Remove() method it works like this:
public void Delete()
{
Record record = new Record() {
id = 1,
value = 5
...
22
votes
1
answer
41k
views
Why use Attach for update Entity Framework 6?
While searching for the best practivies of performing CRUD operation via EF I noticed that it is highly recommended to use Attach() or Find() methods before updating an entity. It works well and ...
1
vote
1
answer
242
views
Can We Auto-generate Controllers and Views Using Dapper
I am working with dapper with c# and mssql . Is there any way that we can autogenerate Controllers and views with dapper as we do with EF.
I thought DapperExtensions will work as they specified
A ...
0
votes
1
answer
118
views
Entity not being saved, DbUpdateException was unhandled
First of all, please note I´ve been checking other questions like this: Unable to update the EntitySet - because it has a DefiningQuery and no <UpdateFunction> element exist
but none of them ...
1
vote
0
answers
88
views
Entity: ForeignKey object is always null
I have a problem (some kind of "two-faced" because in first example code works, in second - not). When I use Create function for Category, field "RootCategory" autofill by Category-object with ...
0
votes
1
answer
5k
views
MVC Master-Detail CRUD [duplicate]
I'm starting with MVC and i have some basic questions that maybe you can orient me a little bit:
I'm Using MVC5 with Razor and EntityFramework 6. No AngularJS skills here.
I have a classic Master-...
1
vote
1
answer
469
views
How to add new row to table, using existing row data in EF6?
Using EF6.
I'm calling a method on my context instance:
var usr = context.Get<User>("Doe");
As I've seen in debug mode, my usr variable stores a link to User class instance. And this instance ...