Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

I need export DbContext to library in nuget package for reutilize in various projects

$
0
0

i have this code in my library

Entrega.cs

[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)]public int Id { get; set; }public string NumeroDeEnvio { get; set; }public int MotivoId { get; set; }public int SubmotivoId { get; set; }public string SucursalId { get; set; }public string CodigoComprobante { get; set; }public string Observaciones { get; set; }public string ResultadoServicioV8 { get; set; }public bool Reintentar { get; set; }public bool Activo { get; set; }public DateTime Created_At { get; }[Timestamp]public DateTime Updated_At { get; set; }

AplicatonContext.cs

public AplicatonContext(DbContextOptions options): base(options) { }public DbSet<Entrega> Entregas { get; set; }protected override void OnModelCreating(ModelBuilder modelBuilder){ }

and in my WebApi when configure servicesstartup.cs

builder.ConfigureServices((ctx, services) =>{    services.AddDbContext<AplicatonContext(opts=> opts.UseSqlServer(ctx.Configuration["ConnectionString"]));

but this code raise exception whit error

System.InvalidOperationException  HResult=0x80131509  Message=The database provider attempted to register an implementation of the 'IRelationalTypeMappingSource' service. This is not a service defined by Entity Framework and as such must be registered as a provider-specific service using the 'TryAddProviderSpecificServices' method.  Source=Microsoft.EntityFrameworkCore

Why is this happening?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>