插入oracle,ASP.NET MVC [英] Insert oracle, ASP.NET MVC
问题描述
我有问题当我在oracle数据库中添加参数时,使用mvc项目
这是错误
https://i.stack.imgur.com/LDhpQ.png
GEolab类
命名空间 WebApplication4.Models
{
使用系统;
使用 System.Collections.Generic;
public partial class GEOLAB
{
public int GEOLAB_ID {获得跨度>; set ; }
public string GEOLAB_NAME { get 跨度>; set ; }
public string GEOLAB_JISHI { get 跨度>; set ; }
public int GEOLAB_ASAKI { get 跨度>; set ; }
}
}
实体类
public partial class 实体11:DbContext
{
public 实体11()
: base ( name = Entities11)
{
}
受保护 覆盖 void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException() ;
}
public DbSet< GEOLAB> GEOLAB {{span class =code-keyword> get ; set ; }
}
connectionstring
< add name = Entities11 connectionString = < span class =code-string> metadata = res://*/Models.EasyDocDB.csdl | res://*/Models.EasyDocDB.ssdl | res://*/Models.EasyDocDB.msl; provider = Oracle .DataAccess.Client; provider connection string = DATA SOURCE = XXX; PASSWORD = XXX; PERSIST SECURITY INFO = True; USER ID = XXX providerName = System.Data.EntityClient />
家庭控制器
使用 System.Data.OracleClient;
使用 System.Data.Entity;
使用 WebApplication4.Models;
使用 WebApplication4.Controllers;
命名空间 WebApplication4.Controllers
{
public class HomeController:Controller
{
//
// 获取:/ Home /
public ActionResult Index()
{
返回查看();
}
public ActionResult list( string name, string jishi, int asaki)
{
Entities11 db = new Entities11();
GEOLAB dg = new GEOLAB()
{
GEOLAB_NAME = name,
GEOLAB_JISHI = jishi,
GEOLAB_ASAKI = asaki
};
db.GEOLABs.Add(dg);
db.SaveChanges();
return View();
}
}
}
这是错误
System.Data.Entity.dll中出现System.ArgumentException类型的异常,但未在用户代码中处理
附加信息:在配置中找不到指定的商店提供商,或者无效。
我尝试了什么:
a尝试更改webconfig connectionstrings
尝试更换
< add 名称 = Entities11 connectionString = metadata = res://*/Models.EasyDocDB。 csdl | res://*/Models.EasyDocDB.ssdl | res://*/Models.EasyDocDB.msl; provider = Oracle.DataAccess.Client; provider connection string = DATA SOURCE = XXX; PASSWORD = XXX; PERSIST SECURITY INFO = True; USER < span class =code-attribute> ID = XXX providerName = System.Data.EntityClient / >
with
< add 名称 = Entities11 connectionString = metadata = res://*/Models.EasyDocDB.csdl | res://*/Models.EasyDocDB.ssdl | res:// * / Models。 EasyDocDB.msl; provider = Oracle.DataAccess.Client; provider connection string = DATA SOURCE = XXX; PASSWORD = XXX; PERSIST SECURITY INFO = True; USER ID = XXX < span class =code-attribute> providerName = System.Data.EntityClient / > 跨度>
i have problem When I add parameters in oracle database, with mvc project
this is error
https://i.stack.imgur.com/LDhpQ.png
GEolab class
namespace WebApplication4.Models
{
using System;
using System.Collections.Generic;
public partial class GEOLAB
{
public int GEOLAB_ID { get; set; }
public string GEOLAB_NAME { get; set; }
public string GEOLAB_JISHI { get; set; }
public int GEOLAB_ASAKI { get; set; }
}
}
entity class
public partial class Entities11 : DbContext
{
public Entities11()
: base("name=Entities11")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<GEOLAB> GEOLABs { get; set; }
}
connectionstring
<add name="Entities11" connectionString="metadata=res://*/Models.EasyDocDB.csdl|res://*/Models.EasyDocDB.ssdl|res://*/Models.EasyDocDB.msl;provider=Oracle.DataAccess.Client;provider connection string="DATA SOURCE=XXX;PASSWORD=XXX;PERSIST SECURITY INFO=True;USER ID=XXX"" providerName="System.Data.EntityClient" />
homecontrollers
using System.Data.OracleClient;
using System.Data.Entity;
using WebApplication4.Models;
using WebApplication4.Controllers;
namespace WebApplication4.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
public ActionResult list(string name, string jishi, int asaki)
{
Entities11 db = new Entities11();
GEOLAB dg = new GEOLAB()
{
GEOLAB_NAME=name,
GEOLAB_JISHI=jishi,
GEOLAB_ASAKI=asaki
};
db.GEOLABs.Add(dg);
db.SaveChanges();
return View();
}
}
}
this is error
An exception of type 'System.ArgumentException' occurred in System.Data.Entity.dll but was not handled in user code
Additional information: The specified store provider cannot be found in the configuration, or is not valid.
What I have tried:
a tried change webconfig connectionstrings
Try to replace
<add name="Entities11" connectionString="metadata=res://*/Models.EasyDocDB.csdl|res://*/Models.EasyDocDB.ssdl|res://*/Models.EasyDocDB.msl;provider=Oracle.DataAccess.Client;provider connection string="DATA SOURCE=XXX;PASSWORD=XXX;PERSIST SECURITY INFO=True;USER ID=XXX"" providerName="System.Data.EntityClient" />
with
<add name="Entities11" connectionString="metadata=res://*/Models.EasyDocDB.csdl|res://*/Models.EasyDocDB.ssdl|res://*/Models.EasyDocDB.msl;provider=Oracle.DataAccess.Client;provider connection string="DATA SOURCE=XXX;PASSWORD=XXX;PERSIST SECURITY INFO=True;USER ID=XXX" providerName="System.Data.EntityClient" />
这篇关于插入oracle,ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!