ado.net-entity-data-model

Oracle ODP.Net With Entity Framework 6 - Entity framework database compatible provider could not be found

拜拜、爱过 提交于 2019-12-29 11:46:17
问题 I am trying to build an MVC 5 Web application with Entity Framework 6 that works on Oracle Database , am trying to use ODAC 12c Release 3 which includes support for Entity Framework 6 Code First and Code First Migrations; NuGet, .NET Framework 4.5.2; and ODP.NET, Managed Driver XML DB. As per http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html I have VS 2013 Community Edition update 4 . Am trying to add Model using ADO.Net Entity Data Model , With Code First. I have the

DbContext declaration - Framework 4.1 - MVC 3.0

别说谁变了你拦得住时间么 提交于 2019-12-25 04:06:59
问题 Is it correct to declare a global variable of "DBContext" in a controller and then use it for all database operations? Example: public class ProductController : Controller { private readonly DBContextEntities _db = new DBContextEntities(); public ActionResult Index() { var products = _db.Products.ToList(); return View(products); } public ActionResult Create() { _db.Products.AddObject(new Product{Name="x",Price="5.2"}); _db.SaveChanges(); return View(products); } } Please Advice, 回答1: I have

How to bind a query with a join to a DataGridView?

泪湿孤枕 提交于 2019-12-23 01:24:16
问题 Right now, I have created a new Object data source based off from an Object Context from the entity model. I then created a BindingSource and a DataGridView set to this BindingSource. I can add columns which are bound to the data from the TraceLine table. When I set the DataSource, I see values in those columns. However, I can’t seem to get the data from the joined table. How do I bind a DataGridView to a query that has a join? using (var entities = new MyEntities()) { var lines = from t in

How to create an Entity Data Model for inherited generic types?

牧云@^-^@ 提交于 2019-12-21 22:17:43
问题 I have no clue how i can get an existing object structure based on the following classes (simplified) into a database using Entity Framework (EF is a constraint, i have to use it). public abstract class WahWahProperty { public string Name { get; set; } public abstract Type PropertyType { get; } } // ---------------- public class WahWahProperty<T> : WahWahProperty { public T Value { get; set; } public override Type PropertyType { get { return typeof(T); } } } // ---------------- public class

Changing the Name of the Connection String that Entity Framework Uses

拟墨画扇 提交于 2019-12-21 08:00:48
问题 How do you change the name of the connection string that Entity Framework models are bound to by default? Let's say I create an Entity Framework data model named "Model1.edmx" by pointing it to a databased named "MyDb" and picking some objects to map using the Visual Studio add new item wizard. The EF model is in a class library project, so when the wizard completed, it automatically added a connection string named "MyDbEntities" to the App.Config file for the project. My model references

asp.net mvc - pass partial data model to partial view

谁说我不能喝 提交于 2019-12-20 23:11:52
问题 I wish to build a partial view that gets a model column and print it. Something like that: At the view: @model IEnumerable<products_comparison.Models.Product> @{ ViewBag.Title = "Index"; var Brand = (from r in Model select r.Brand).Distinct(); } <h2> Index</h2> @Html.RenderPartial("_DisplayAttribute",Brand) And at the partial view: <table> <tr> <th> Brand </th> </tr> @foreach (var row in Model) { <tr> <td> @Html.DisplayFor(r => row) </td> </tr> } </table> There are a few problems I run into:

How can I add constraints to an ADO.NET Entity?

╄→гoц情女王★ 提交于 2019-12-18 05:55:54
问题 I know how to mark a group of fields as primary key in ADO.NET entities but i haven't found a way to declare unique constraints or check constraints. Is this feature missing on the designer or on the framework? 回答1: Support for unique keys/constraints does not exist in ADO.NET Entities in v4.0, see the answer to "one-to-one association on a foreign key with unique constraint", where Diego B Vega says: I know for sure we haven't added support for unique keys other than primary keys in 4.0. He

Entity Framework - Inserting entity with multiple models and databases

折月煮酒 提交于 2019-12-18 01:19:58
问题 I have my domain split into multiple Entity Framework models. I have some shared entities that span multiple models (named Lookup), however, these are replaced with "using" references using the methods described in Working With Large Models In Entity Framework. However, what makes my case slightly more unique is that I'm also separating these models into multiple databases (one per model). I'm having a problem inserting one of my shared entities into my common DB. It's failing with the error:

Returning datatable using entity framework

穿精又带淫゛_ 提交于 2019-12-17 19:27:49
问题 I am using entity framework. There is one particular situation in my application where I have to use a stored procedure. Since there are a lot of SQL statements written in the SP, I don't want to re-write it in my C# code. I only need to get the result back in the form of a datatable. I have written a little bit of code but I am stuck at one point. Can someone complete the code below? using (dbContext.Database.Connection) { dbContext.Database.Connection.Open(); DbCommand cmdItems= dbContext

Entity Framework 4: Does it make sense to create a single diagram for all entities?

心不动则不痛 提交于 2019-12-17 15:22:49
问题 I wrote a few assumptions regarding Entity Framework, then a few questions (so please correct where I am wrong). I am trying to use POCOs with EF 4. My assumptions: Only one data context can exist for an EF diagram. Data Contexts can refer to more than one entity. If you have two data sources, say MS SQL server and Oracle, EF requires two different diagrams to access the data. The EF diagram data context is the "Unit of Work", having a single Save() for anything on the diagram. (Sure you