asp.net-mvc


EF Core + MVC 6 + .NET Core RC2 - EF not returning results


Entity Framework Core is not returning any results. I've been searching near and far. I find some tutorials saying one thing and others saying another. Here is what I have so far:
Buyer.cs
[Table("DealerCustomer", Schema = "dbo")]
public class Buyer
{
[Key]
public int DealerCustomerKey { get; set; }
public int DealerId { get; set; }
}
BuyerContext.cs
public class BuyerContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.UseSqlServer("db connection string here");
}
public DbSet<Buyer> Buyers { get; set; }
}
Startup.cs > ConfigureServices function
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddDbContext<BuyerContext>(options =>
options.UseSqlServer("db connection string here");
services.AddMvc();
}
Now I am trying to load the Buyers data from my BuyerController.cs:
[Route("api/[controller]")]
public class BuyersController : Controller
{
private BuyerContext _context;
public BuyersController(BuyerContext context)
{
_context = context;
}
[HttpGet]
public IEnumerable<Buyer> Get()
{
System.Diagnostics.Debug.WriteLine("getting buyers");
System.Diagnostics.Debug.WriteLine(_context.Buyers);
return _context.Buyers;
}
}
This is all returning empty brackets when I load the page, instead of a list of Buyers. However there are over 1000 rows in that table (dbo.DealerCustomer). I know I have two places adding the db connection string but tutorials kept show both ways of doing it and when I only did it in startup.cs I was getting errors about the _context. I can make everything look pretty later, right now I just want a good connection so I have a starting place to work from.
I found there was a timeout because one of the decimal fields was returning null.
EF Core Timing out on null response

Related Links

Unable to debug plugin in NopCommerce
Displaying HTML and Images in MultiSelectList ASP.NET MVC Razor
#Html.DisplayFor() value not change after the postback
Location of Validation Message
ASP.NET Identity update column type for primary key Id in AspNetUsers table from a string to and int or a guid, yes or no?
Deploying ASP MVC 5 App with IIS 7.5
validation for dropdown in MVC3
MVC getting a list of music and image into a table
How to allow users to only edit their details in a catalog
Defining Repository for MVC best practice
MVC ASP.NET search filter by int
How do I add placeholder text from the model into a MVC view?
Web site analytic application in the mvc application
mvc3 EditorFor/DisplayFor throws Collection was modified; enumeration operation may not execute
When I update ASP.NET MVC from 5.0 to 5.1, do I need to update the bindingRedirect to 5.1?
Set ClaimsAuthorizationManager in Code (MVC 5)

Categories

HOME
embedded-linux
x-editable
android-wear
apacheds
linear-programming
weight
localforage
streaming
antlr
stripe-payments
google-analytics-api
classloader
akka.net
range
ceph
overloading
zebble
cytoscape.js
pouchdb
command-line-interface
nanotime
graph-tool
fbx
raspberry-pi2
data-annotations
w2ui
html-email
curve-fitting
jmeter-plugins
many-to-many
rgdal
azure-ad-graph-api
hough-transform
montecarlo
cadvisor
liferay-aui
popupwindow
gcp
jsplumb
angular2-databinding
scatter-plot
panel-data
django-users
chai
subtotal
dwm
packaging
sourcetree
knowledge-management
amazon-vpc
pac
consistency
dxgi
automata-theory
rating
free-diameter
zfs
move
manual
surroundscm
measurement-protocol
webtrends
pygments
ng-annotate
kernighan-and-ritchie
pager
network-traffic
submission
namenode
google-api-ruby-client
dual-table
nominatim
netbsd
vbo
linegraph
ehcache-bigmemory
generalization
theorem-proving
twitter-follow
scribe
bit.ly
dynamic-data-display
deepzoom
android-c2dm
qt4.7
couchrest
vlfeat
pubdate
arbtt
tempo
mknetworkkit
ed
proxy-classes
codi
custom-tag
system-tray
mkmapviewdelegate
n900
scramble
xtratreelist
markitup
non-relational-database
geneva-framework
palm-pre
mud
large-teams
plumtree

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App