EntityFramework with service app fabric .net core stateless API SNI.dll not found error

179 Views Asked by At

I am trying to migrate my .net Web API application to Service app Fabric stateless .net core API. I want to use the entity framework. When I am trying to query on my db table so I am getting error "Failed to load C:\SfDevCluster\Data\_App\_Node_0\DRIHubType_App3\MUACAPIPkg.Code.1.0.0\x64\SNI.dll"

I tried all the things like adding sqlclient 4.0.0 reference, changed the framework to 4.6 etc. but nothing is working for me.

public class DatabaseContext : DbContext
{
       public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options)
       {

       }
       public DbSet<Pubsuite> Pubsuite { get; set; }
    }
    ==Startup Class code

    services.AddDbContext<DatabaseContext>(opts => opts.UseSqlServer("server=srvername;database=dbname;User ID=user;password=password;"));

    ====Pubsuite class

    public class Pubsuite
    {
         [Key]
         public string username { get; set; }
         public string pubsuites { get; set; }
    }

     public interface IPubsuiteRepository<T>
     {
            IEnumerable<T> GetPubsuites();
     }


     public class PubsuiteRepository : IPubsuiteRepository<Pubsuite>
     {
            readonly DatabaseContext _libraryContext;

            public PubsuiteRepository(DatabaseContext context)
            {
                _libraryContext = context;
            }

            public IEnumerable<Pubsuite> GetPubsuites()
            {
                return _libraryContext.Pubsuite.ToList();
            }
    }

    public class ValuesController : ControllerBase
    {
            private readonly IPubsuiteRepository<Pubsuite> _libraryRepository;

            public ValuesController(IPubsuiteRepository<Pubsuite> libraryRepository)
            {
                _libraryRepository = libraryRepository;
            }

            // GET api/values
            [HttpGet]
            public ActionResult<IEnumerable<string>> Get()
            {
                try
                {
                    IEnumerable<Pubsuite> authors = _libraryRepository.GetPubsuites();
                    return new string[] { "value1", "value2" };
                }
                catch (Exception ex)
                {
                    var mess = ex.Message;
                    return new string[] { mess };
                }

            }
        }
    }

error:-

IEnumerable authors = _libraryRepository.GetPubsuites();

I am getting error on the above line.

1

There are 1 best solutions below

0
Abhinav Sharma On

The solution to the above problem is, just install the visual studio 2019. Actually the latest package of Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore is 3.1 . I think it is more suitable for 2019.