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="Data Source=localhost;Initial Catalog=RCUM;User ID=sa;Password=***** " providerName="System.Data.EntityClient" /></connectionStrings>
Kindly help me