dbcontext

How to stop the EDMX generator from changing columns names

橙三吉。 提交于 2020-01-07 02:31:35
问题 If a table has column names that are the same as the table name the EDMX Generator suffixes the column name with a "1". Ex: Changing Test to Test1 in the sample below. SQL Server Table definition: CREATE TABLE [dbo].[Test]( [Test] nchar NOT NULL, [ColumnsTwo] nchar NULL, EF Model created: <EntitySetMapping Name="Test"> <EntityTypeMapping TypeName="AdventureWorksModel.Test"> <MappingFragment StoreEntitySet="Test"> <ScalarProperty Name="ColumnsTwo" ColumnName="ColumnsTwo" /> <ScalarProperty

How to stop the EDMX generator from changing columns names

£可爱£侵袭症+ 提交于 2020-01-07 02:31:06
问题 If a table has column names that are the same as the table name the EDMX Generator suffixes the column name with a "1". Ex: Changing Test to Test1 in the sample below. SQL Server Table definition: CREATE TABLE [dbo].[Test]( [Test] nchar NOT NULL, [ColumnsTwo] nchar NULL, EF Model created: <EntitySetMapping Name="Test"> <EntityTypeMapping TypeName="AdventureWorksModel.Test"> <MappingFragment StoreEntitySet="Test"> <ScalarProperty Name="ColumnsTwo" ColumnName="ColumnsTwo" /> <ScalarProperty

WCF, Entity Framework 4.1 and Entity's State

☆樱花仙子☆ 提交于 2020-01-06 05:39:06
问题 I am developing an application which will expose WCF services. I am using Entity Framework 4.1 at the DAL. The problem is when I load some entity (let say a Customer that has Order which in turn has OrderDetail). After loading it I make some changes in Customer, Order and OrderDetail objects (some new orders are added and some existing orders are removed/updated) and send the object graph to WCF service to update it as following. Customer oCustomer; using(var context = new MyContext) /

OWIN DbContext and a single DbContext for all of my Repositories

匆匆过客 提交于 2020-01-04 19:38:56
问题 I am building a ASP.NET MVC application. I'm new to the whole Repositories/Unit Of Work patterns. I'm part way through implementing a generic repository for my EF objects. I realise that there is an issue with ensuring that you only have a single DbContext per Http request... I'm pretty sure that I can achieve this by creating an instance using OWIN. /// <summary> /// Configures OWIN /// </summary> /// <param name="app"></param> public void Configuration(IAppBuilder app) { // Create instance

Issue creating DbContext connection with LINQPad using Entity Framework 6.0 code first

时间秒杀一切 提交于 2020-01-04 15:29:19
问题 I'm using LINQPad v4.51.03 and attempting to create a DbContext connection from a code-first implementation in Entity Framework 6.0 (6.1.1). public partial class MyEntities : DbContext { public MyEntities() : base("mydbname") { ... The connection string looks like: <add name="mydbname" connectionString="Data Source=<db>;initial catalog=<cat>;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.EntityClient" /> In the LINQPad 'Add

'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type parameter 'TContext'

大城市里の小女人 提交于 2020-01-03 08:53:12
问题 It's my first time using asp 5\core1 and i'm having problem setting a entity framework dbcontext I have one class library with my object public class Utilizador { public Utilizador() { } public int id { get; set; } } Then i have a Web Api project with a reference to my class and a context public class Context : DbContext { public Context(DbContextOptions<Context> options) : base(options) { } public DbSet<Utilizador> Utilizadores { get; set; } } My package.json its like this regarding entity

'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type parameter 'TContext'

主宰稳场 提交于 2020-01-03 08:53:08
问题 It's my first time using asp 5\core1 and i'm having problem setting a entity framework dbcontext I have one class library with my object public class Utilizador { public Utilizador() { } public int id { get; set; } } Then i have a Web Api project with a reference to my class and a context public class Context : DbContext { public Context(DbContextOptions<Context> options) : base(options) { } public DbSet<Utilizador> Utilizadores { get; set; } } My package.json its like this regarding entity

The provider did not return a ProviderManifestToken string error

旧巷老猫 提交于 2020-01-01 04:05:29
问题 I am trying to create a web app using ASP.Net MVC3, Entity Framework and MySQL. I have added the following code to my Web.Config file. <connectionStrings> <add name="ContactContext" connectionString="server=localhost;database=contacts;uid=root;pwd=password;" providerName="MySql.Data.MySqlClient"/> </connectionStrings> I also have created "Person" Model , "ContactContext" in the project "Contact_Me". When I try to create a "ContactController" including Person Model and Contact context, it

Which one must I use, MyDbContext.Blogs.Add(ablog) or MyDbContext.Add(ablog)?

♀尐吖头ヾ 提交于 2019-12-31 04:23:06
问题 Consider I have a context MyDbContext inherits DbContext of EFCore 2.0. Blogs is a DbSet<Blog> and Blog is an entity model. When I add a new Blog instance, ablog to the Blogs , which one must I use? MyDbContext.Add(ablog); or MyDbContext.Blogs.Add(ablog); ? How about Find ? MyDbContext.Find<Blog>(1); or MyDbContext.Blogs.Find(1); ? Is there any benefit to use one over the other one? 回答1: Adding directly data via the DbContext is new to the DbContext in Entity Framework Core and have no

The entity type is not part of the model, EF 5

耗尽温柔 提交于 2019-12-30 08:42:52
问题 I am trying to update my repository to EF5 but have encountered a few errors. I've taken a look around stackoverflow for similar errors discovered a few questions/answers but unfortunately the same answers didn't resolve my issue. This is my error: The entity type User is not part of the model for the current context. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it