Asked by:
Exception user unhandled

Question
-
User-605499000 posted
I keep going from appplicationdbcontext file to program files errors.
Below is the error message I am using aspnet core mvc 3.1
System.TypeLoadException: 'Method 'Create' in type 'Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlTranslatingExpressionVisitorFactory' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'
Here is the ApplicationDBContext file
using Bumples15.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;namespace Bumples15.Data
{
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) //here is the error
{
}
public DbSet<Product> Products { get; set; }public DbSet<Order> Orders { get; set; }
}
}Below is the program file;
namespace Bumples15
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});}
}here is the startup file:
using Bumples15.Data;
using Bumples15.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;namespace Bumples15
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{services.AddControllersWithViews();
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));services.AddIdentity<IdentityUser, IdentityRole>()
.AddDefaultUI()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddScoped<RoleManager<IdentityRole>>();
services.AddScoped<IRepository<Product>, SqlBooksRepository>();
services.AddScoped<IRepository<Order>, SqlOrdersRepository>();services.AddRazorPages();
services.AddRazorPages();
}// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();}
app.UseHttpsRedirection();
app.UseStaticFiles();app.UseRouting();
app.UseAuthentication();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
}
}
}Some of the programs were files taken from aspnet core mvc 2.1. But I think that I have upgraded them all.
Is that where my problem is:
Thanks
Jen
Friday, May 8, 2020 10:02 PM
All replies
-
User-854763662 posted
Hi bumples18 ,
Some of the programs were files taken from aspnet core mvc 2.1What is the version information of all packages you installed ? Show your project.csproj file.
It would be better if you share a complete project that can reproduce the issue, currently we cannot find the problem based on the existing code.
Best Regards,
Sherry
Sunday, May 10, 2020 7:15 AM -
User-605499000 posted
Hi again,
You suggested looking at the csproj file which I did. I found files that were loaded with the newest updates like tested 5.0. I replaced those files to 3.1 that was safe and my problems went away. I no longer had ApplicationDbContext errors.
Once again you have been a great help and I thank you again.
Jjen
Monday, May 11, 2020 9:43 PM -
User-605499000 posted
Sorry I marked this as answered a couple of days ago. You did an excellent job and I can't thank you enough.
Jen
Friday, May 15, 2020 3:33 PM