ef-database-first

Using MVC 4 SimpleMembership with an existing database-first EF model

这一生的挚爱 提交于 2019-12-28 10:07:25
问题 I am trying to use SimpleMembership in my MVC 4 for the first time and I already have an existing database and EF5 model created based on it! I searched a lot but I cant find how I could use it in my case and also to have everything under my own model. It would be great if somebody can give me an idea how to do this. Thanks 回答1: Purely as a point of reference, it might be a good idea to create a new Internet Application template of an ASP.NET MVC 4 Web Application project (i.e. via File > New

Database First with Bridge Table, How to Keep It Out of Model

你说的曾经没有我的故事 提交于 2019-12-24 02:12:34
问题 I am trying to find out how I can make a bridge table entity, used for a many to many relationship, transparent to my model. I am using EF Database First . Tables in question ...(simplified) Report - ReportId INT PK - ReportName VARCHAR(50) Group - GroupId INT PK - GroupName VARCHAR(50) ReportGroup - ReportId INT PK - GroupId INT PK Current Class Structure ...(simplified) public class Report { public int ReportId { get; set; } public string ReportName { get; set; } public IList<ReportGroup>

How to get MVC-mini-profiler working on EF 4.1 Database First

大城市里の小女人 提交于 2019-12-24 00:14:12
问题 Spent better part of the day combing through SO for this. Here's the setup MVC 3 App using Repository pattern with 3 repositories across 2 databases. EF 4.1 Database first using the DBContext API for both db connections. Installed mvc-mini-profiler from nuget This is how I create my Db Context in the repository public class TransactionRepository : BaseRepository, ITransactionRepository { AccountingEntities _db = new AccountingEntities(); // repository methods } Then in controllers public

Force DateTime with Entity Framework Database First

落爺英雄遲暮 提交于 2019-12-23 23:26:39
问题 I am connecting to a database using EF database first. Therefore my models are autogenerated. When I update a record my DateTimes are getting written as SQL type DateTime2. The production server is SQL Server 2005 (no comments please), so the updates fail as DateTime2 is not supported. I've tried creating a metadata class for my model as per http://www.asp.net/mvc/overview/getting-started/database-first-development/enhancing-data-validation and decorating the member with [Column(DbType =

Entity Framework Core Database-First Update after initial Scaffold?

自作多情 提交于 2019-12-23 07:17:06
问题 I'm playing around with Entity Framework Core and I have been working on implementing a Database-First application. The initial Scaffold-DbContext command works just fine and creates all my entities correctly, if not organized as I would like. It's a SQL Server database that uses schemas to break up areas of responsibility and I don't really care for the fact that the Scaffold just throws them all into a single folder. That aside, I have been unable to determine if there is a way to re-run

Entity framework 6 usetransaction databasefirst throws UnintentionalCodeFirstException

谁说我不能喝 提交于 2019-12-23 00:44:09
问题 I'm trying to execute the following : SqlConnection cnSql = new SqlConnection(cnstring); cnSql.Open(); SqlTransaction Transactie = default(SqlTransaction); Transactie = cnSql.BeginTransaction(); SqlCommand cmddelbonh = new SqlCommand(); cmddelbonh.Connection = Transactie.Connection; cmddelbonh.Transaction = Transactie; cmddelbonh.CommandText = "update artikelgroepen set OMSN='XXXXX' where ID = 3"; cmddelbonh.ExecuteNonQuery(); using (CXNACC_TESTFIRMA cxn = new CXNACC_TESTFIRMA(cnSql)) { cxn

Entity Framework mapping two table columns to same related table Key

流过昼夜 提交于 2019-12-22 11:29:30
问题 I'm in a situation where I have a table called Elements . Now I'm creating a table called Divergences that will store basically pairs of Elements . The purpose of Divergence is to check if two Elements have diverging answers. Element Divergence --------- ---------- ElementId ElementId1 ElementId2 In the above table schema, ElementId1 and ElementId2 are Foreign Keys mapping to ElementId in Elements table and form the composite primary key for the Divergence table. I use Database First approach

MySql Connector with EF 6

眉间皱痕 提交于 2019-12-22 07:06:30
问题 I am having a weird issue with MySql Connector(6.8.3) and EF6. I was working on a WebApi project where I use MySql and EF6 with Database first approach. Everything worked fine[even deployed on one of the test servers] until I changed the database from 'Test' database to 'Production' database [just the database name] in the connection string and updated the model[just to see nothing is broken!]. After that, it failed to connect to database. So, I changed the connection string back and rebuilt

Any Fluent API tutorials that use EF Database-First approach to explain the subject?

大城市里の小女人 提交于 2019-12-21 02:44:05
问题 There are many tutorials on Fluent API, but they all explain it using Entity Framework Code-First code examples. Since I don't know Code-First, do you know of any Fluent API tutorials that would explain the subject using EF Database-First approach? Thank you 回答1: There are no tutorials which would explain the Fluent API together with Database-First approach because Fluent API is made only for Code-First approach. You don't need the Fluent API if you want to create your model via Database

Entity Framework 5, switch from code first to database first?

我只是一个虾纸丫 提交于 2019-12-20 14:41:55
问题 I've already created a database using code first. It worked well. Many changes have since been made to the database outside Visual Studio. So many that any attempt at migration generates errors. So my question is, is there a way to switch a solution from code first to database first? 回答1: This should be easy, just create a new, database first model and delete your code first model. Most of your code will compile just fine if you are in the same namespace and take care of naming your context