Help

using entity framework in maui.net

757 0
cancel
Showing results for 
Search instead for 
Did you mean: 
babucr
4 - Data Explorer
4 - Data Explorer

Hai,

I am trying to connect Airtable in .net maui. I installed Airtable 1.4.0 ,AirtableEfcore 1.1.0 and CData.Airtable.EntityFrameworkCore. This is my code

public class TestDbContext : DbContext
{
public TestDbContext(DbContextOptions options) : base(options)
{
}

public DbSet<Student> Master { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}

public class Student
{
public string Id { get; set; }
public string Name { get; set; }
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var services = new ServiceCollection();

services.AddDbContext<TestDbContext>(o => o.UseAirtable("app66666Xep", "patSOBFs83Vv6"));
var sp = services.BuildServiceProvider();

var scope = sp.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<TestDbContext>();
TestDbContext Db;

var x = db.Master.ToList();

}

But I could not get a connection Services is null.

Please help how to get connected. 

Thanks

 

0 Replies 0