[Solved] ASP.Net MVC Entity framework Error: Unable to load the specified metadata resource

rajeesh
 
on Feb 22, 2021 12:28 AM
1854 Views

Dear sir,

I am a beginer in asp.net mvc. I created a insert project but would not insert in database.

C# ERROR

An exception of type 'System.Data.Entity.Core.MetadataException' occurred in EntityFramework.dll but was not handled in user code
 
Additional information: Unable to load the specified metadata resource.

 

        [HttpGet]
        public ActionResult AddOrEdit(int id=0)
        {
            tblnewregistration userModel = new tblnewregistration();
            return View(userModel);
        }
        [HttpPost]
        public ActionResult AddOrEdit(tblnewregistration userModel)
        {
            using(DbModels dbModel=new DbModels())
            {
                if (dbModel.tblnewregistrations.Any(x => x.Username == userModel.Username))
                {
                    ViewBag.DuplicateMessage = "Username already exist";
                    return View("AddOrEdit", userModel);
                }
                else
                {
                    dbModel.tblnewregistrations.Add(userModel);
                    dbModel.SaveChanges();
                }
            }
            ModelState.Clear();
            ViewBag.SuccessMessage = "Registration Successful";
            return View("AddOrEdit");
        }

 

<add name="DbModels" connectionString="metadata=res://*/Models.DbModels.csdl|res://*/Models.DbModels.ssdl|res://*/Models.DbModels.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=RCUM;User ID=sa;Password=***** " providerName="System.Data.EntityClient" /></connectionStrings>

Kindly help me

Download FREE API for Word, Excel and PDF in ASP.Net: Download