All Questions
Tagged with entity-framework-core asp.net-mvc
593
questions
0
votes
0
answers
44
views
Unable to create a 'DbContext' of type '' whenever I try to add migration
The problem occurs whenever I try to add migration with any kind of DbSet. When I leave all of the dbsets commented the ApplicationDbContext instance exists. I have searched throughout all similar ...
2
votes
1
answer
51
views
A Possible Object Cycle was detected error [duplicate]
I get this error when i try to request this Controller
The errror message
JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than ...
0
votes
0
answers
63
views
Key constraints in EF Core
Knowing that a PK can be a FK at the same time, I just want to make use of the data annotations attributes available in EF core to make this possible for the below entities (models) in C#:
public ...
0
votes
1
answer
40
views
Join 3 tables with EF code first approach
There are jobs. you can post CVs for multiple jobs .Employer can accept or decline CVs
I have 3 models
public class Job
{
public int Id{ get; set; }
public string Title{ get; set; }
...
0
votes
1
answer
21
views
How to reload the Create view after AJAX Post?
I have two Model Classes, Telephone and Telephone Model.
To create a new Telephone it is necessary to choose a TelephoneModel.
I want to add within the Telephone Create View, a Modal to create a ...
0
votes
1
answer
43
views
Since this is an async method, the return expression must be of type 'Data' rather than 'Task<Data>' error in ASP.NET and Entity Framework
[HttpGet]
public async Task<IActionResult> View(Guid id)
{
var employee = await mvcDemoDbContext.Employees.FirstOrDefaultAsync(x => x.Id == id);
if(employee != null)
{
...
0
votes
0
answers
227
views
Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call
I was trying to connect mysql server using entity framework. I installed two nuget packages which are Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools. Here it is my ...
0
votes
0
answers
21
views
complex migrations with moving data
I have asp .net core application. I would like to split table with data into the more parts and migrate some data from one table into the new one. Is there a way how to do that?
Before:
table_a
-------...
0
votes
1
answer
63
views
Pagination in .net core mvc 6.0 is not working
I am trying to add pagination to my .net core mvc 6.0 project for that I have created a pagination class here is the code
public class PaginatedList<T>: List<T>
{
public int PageIndex {...
0
votes
1
answer
29
views
.NET EntityFrameWork adds extra data
I am writing MVC Web API with .NET. When I add data to one of the models that reference each other, data is also added to the database of the other model.
City:
public class City
{
public City()
...
0
votes
0
answers
88
views
Unable to create a 'DbContext' of type ''.The exception'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions
Unable to create a 'DbContext' of type ''. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[Magazin_Online.Data.AppDbContext]' while attempting to ...
1
vote
1
answer
62
views
Filter inside Create view in ASP.NET MVC
Need some advice on the correct approach for the next scenario.
I have three model classes:
namespace App.Models
{
public partial class Company
{
[Key]
public int ID { get; set;...
0
votes
0
answers
65
views
await _context.SaveChangesAsync(); not working
What is wrong with this code? _context.Images.Add(image) works but await _context.SaveChangesAsync(); doesn't work. There is no error/exception. A row is created in the database table but the BLOB ...
0
votes
1
answer
52
views
Creating an ASP.NET app with crud functionatility but not able to create new products as the ModelState.IsValid is false
I am writing an ASP.NET MVC web app with crud functionalities and my ModelState.IsValid is always returning false when I click on the create button. When I added some debugging, it shows that the drop ...
2
votes
2
answers
2k
views
Unable to create a 'DbContext' of type '' while trying to migrate database
I have a Asp.Net project where I try to migrate a Database with a DbContext.
Unfortunately, I get the Error
Unable to create a 'DbContext' of type ''. The exception 'Unable to resolve service for ...