you question is not clear. elasticsearch is an index service with an api. while NEST supplies a fluent api, it has nothing to do with entity framework.
see:
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I would like to know how I could connect to elasticsearch with .net core mvc (.net 6) utilizing entityframework core, and then get the data to display on my view.
NUGET NEST (7.17.2) is installed.
I have a BuildingViewModel:
public class BuildingViewModel
{
public string? Id { get; set; }
public string? Building { get; set; }
public string? Keeper { get; set; }
}
Connection string setting in appsettings.json (I have a default connection to another database for User Identity
{
"ConnectionStrings": {
"DefaultConnection": "other connection string",
"ElasticConnection": "Server :'my server IP', Port:'9200', Index :'my_index', UserName:'my_username', Password:'my_password'"
}
}
Program.cs
ElasticDbContext.cs
public class ElasticDbContext : DbContext
{
public ElasticDbContext(DbContextOptions<ElasticDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new ElasticClientConfiguration());
}
public DbSet<BuildingViewModel> Buildings { get; set; }
}
I am stuck on how I could open the connection in my controller and use the data in my view.
I have did some research but I do not wish to create a search bar in my view but instead I will search in my controller and simply display the data as graphs in my view. Please let me know how this could be done. Thanks!
you question is not clear. elasticsearch is an index service with an api. while NEST supplies a fluent api, it has nothing to do with entity framework.
see: