edmx

How to call Database.SetInitializer on model-first?

假如想象 提交于 2020-01-02 06:31:29
问题 I created a model in the edm designer (VS10) using "DbContext Entity Generator" as the generation item. In the generated DbContext subclass, it overrode the constructor so I can't use it in the other partial class: public EntitiesContainer() : base("name=EntitiesContainer") { this.Configuration.LazyLoadingEnabled = false; } What's the proper way of initialize a database with model-first? 回答1: You could alter the T4 template that's being used for generating the DbContxt class. Then you could

Entity framework error on updating model from database and vice versa

微笑、不失礼 提交于 2020-01-01 09:42:13
问题 Here is what happens when I try to update model from database with VS express 2013 for the web, EF6.1.1 and .NET framework 4.5. In this case I just added a field to a table in the table definition and updated the database. After that I right click update model from database in the EDMX model view and I get this error message: An exception of type ‘System.runtime.interopServices.COMException’ occurred while attempting to update from the database. The exception message is: ‘A file or folder

I can't update my edmx since the Entity Data Model Designer is unable to open it

做~自己de王妃 提交于 2019-12-29 09:59:08
问题 Hi everyone and thanks for taking the time to see my question. I'm running VS 2017 with Entity Framework 6 and asp.net MVC and have to add some field to one of my Entities. I added the corresponding fields in the database, but when I open the edmx file nothing shows apart the message "Entity Data Model Designer is unable to open this file." and it proposes me to open it in XML editor, but I have not the "Update model from Database" option when right clicking on the XML file. Is anyone knows

How to insert model from mapping table

喜欢而已 提交于 2019-12-25 03:10:17
问题 I have idea to insert my model from excel using mapping from table. Because my excel hv more then 100 column. It will be tired if I code manualy like I do. I hv idea to save to database the name of header excel, the function, and row for my table First, I read my excel then capture to dataset, then foreach dataset, then for each list mapping, then using if to know is empty or not, then read function using replace, then set model using mapping table What I do: [HttpPost] public ActionResult

Entity Framework TT template -> Navigation Property name based on foreign key ID

故事扮演 提交于 2019-12-24 11:13:31
问题 I have the following table: CREATE TABLE Phone( PhoneId INT IDENTITY (1, 1) NOT NULL, CONSTRAINT PK_Phone PRIMARY KEY CLUSTERED (PhoneId ASC)) CREATE TABLE Person( PersonId INT IDENTITY (1, 1) NOT NULL, MobilePhoneId INT NOT NULL, PhoneId INT NOT NULL, ... CONSTRAINT PK_Person PRIMARY KEY CLUSTERED (PersonId ASC), CONSTRAINT FK_Projects_Phone FOREIGN KEY (PhoneId) REFERENCES Phone(PhoneId), CONSTRAINT FK_Projects_MobileId FOREIGN KEY (MobilePhoneId) REFERENCES Phone(PhoneId), ... I am using

Visual Studios for Mac: Unable to load the specified metadata resource

萝らか妹 提交于 2019-12-24 07:58:38
问题 In my C# Project I use Database First development using Entity Framework. The model is stored in an EDMX file (.edmx extension) in my project. This process automatically created a connection string as follows in my App.config: <add name="TableEntities" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl ... This project has been thoroughly tested on 'Visual Studios 2015 - Windows' and works flawlessly. Pulling the same repo in the 'Visual Studios for Mac'

Controlling how often an Entity Framework ObjectContext is created

≡放荡痞女 提交于 2019-12-24 01:49:17
问题 I have a rather large SQL backed ASP.NET project that uses Entity Framework to interact with the database. My question is, should I create an instance of the ObjectContext defined by the edmx/designer files in each class/method -or- wrap it around a static class that would instantiate onload and basically handle all requests through one instance. I will have multiple users using the ObjectContext to read and update the DB, concurrency and thread safety are my utmost concerns. EDIT: This code

EDMX Connectionstring 'name'

我的未来我决定 提交于 2019-12-24 00:57:55
问题 We have generated this connectionstring (below) via Edmx: <add name="Connection" connectionString="metadata=res://*/Code.aa.csdl|res://*/Code.aa.ssdl|res://*/Code.aa.msl;provider=System.Data.SqlClient;provider connection string="data source=server.com;initial catalog=db_name;persist security info=True;user id=user;password=pwd;multipleactiveresultsets=True;application name=EntityFramework;"" providerName="System.Data.EntityClient" /> However, running the application will get us the following

Entity Designer missing

前提是你 提交于 2019-12-23 11:47:27
问题 As the title says, somehow the entity designer disappeared from my installation of Visual Studio 2010. When trying to open an .edmx file, it only opens it in the XML editor. When i choose "Open With...", the Entity designer doesn't show up in the list. It has worked before, and i don't know of anything i could have done to remove it from the list. Does anyone know how i can re-add it? Thanks! 回答1: First thing to check is, is this a problem with your project or with your VS installation. Try

Entity Designer missing

◇◆丶佛笑我妖孽 提交于 2019-12-23 11:46:13
问题 As the title says, somehow the entity designer disappeared from my installation of Visual Studio 2010. When trying to open an .edmx file, it only opens it in the XML editor. When i choose "Open With...", the Entity designer doesn't show up in the list. It has worked before, and i don't know of anything i could have done to remove it from the list. Does anyone know how i can re-add it? Thanks! 回答1: First thing to check is, is this a problem with your project or with your VS installation. Try