c# - Oracle DbContext .NET -
hi first post here. using dbcontext data oracle database. tell me please, doing wrong. no errors no data.
public class oraclecontext : dbcontext { public oraclecontext() : base("oracleconnection") { } public dbset<role> roles { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.entity<role>().totable("roles"); modelbuilder.entity<role>().property(role => role.role_id).hascolumnname("role_id").hascolumntype(""); modelbuilder.entity<role>().property(role => role.user_role).hascolumnname("user_role").hascolumntype("varchar"); base.onmodelcreating(modelbuilder); } } public class role { [key] public int role_id { get; set; } public string user_role { get; set; } }
and controller:
public actionresult index() { oraclecontext ctx = new oraclecontext(); viewbag.c = ctx.roles.count(); return view(); }
Comments
Post a Comment