ef-model-first

Adding reference to entity causing Exception

左心房为你撑大大i 提交于 2019-12-12 05:27:07
问题 I have a model as shown below (created using Model-First approach). A book is a selling item. A DigitalDisc is a selling item. This is working fine and data is getting inserted correctly in database. I am adding a new entity named “Purchase”. One purchase contains multiple sellingitems. Once I added this new association and updated the database schema, I am getting the following exception. An error occurred while updating the entries. "The INSERT statement conflicted with the FOREIGN KEY

DbContext fails to initialize Model-first database

六月ゝ 毕业季﹏ 提交于 2019-12-11 13:25:08
问题 Update : It turns out I had (hidden away in my POCO objects) a property with an abstract type. Removing this property solves the issue. I'm trying to have a model-first scenario with entity framework 4 ctp 5 generate my database (currently using a SQL Server CE4 backend, but I can reproduce on a Sql Server 2008 backend) from my model. I think I might have messed up my model definition somehow, but I can't seem to figure out how and the error message leaves me none the wiser. My DbContext

Entityframework model first decimal precision

Deadly 提交于 2019-12-11 09:57:14
问题 I'm using Entityframework 6 with model first. In the diagram I have chosen decimal for my datatype. When I save decimal values, the database only has whole numbers and the decimals get dropped. My first suspicion was to check the precision, however going to the properties window from the model first diagram designer, the precision and scale dropdowns have no other options besides "None". How do I get EF to save my decimals? Is it a precision issue? If so, how do I set the precision in this

Entity Framework (.NET) Round-Trip Modelling with Model First?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 09:53:08
问题 I am currently working on a project where I want to use the Entity Framework for the first time. I read much information in the books of Lerman/Miller, in MSDN, the ADO.NET blog and here on stackoverflow about the most recent developments regarding the DbContext API and the Code First Migrations capabilities available since EF 4.3. Since especially the latter are really great, I wondered whether in the meantime it is possible to do the same working "Model First" centered? Is it possible to do

Model First database generator freezes my Visual Studio

梦想与她 提交于 2019-12-11 03:54:40
问题 I'm new to the Entity Framework, and I know this is not suppose to happen, but maybe it is a known issue in the community so I thought I'd ask. I created my model with 2 entities. When I wanted to create the database tables Visual Studio froze on me. I ran the script myself but then I needed to modify an attribute so it'd take null values, and againg I can't impact my new model to the database. I looked for upgrades or anything with no luck. Is anybody experiencing anything like that? 回答1: I

Entity Framework Model First Navigation Properties adding invalid column names to query?

时光怂恿深爱的人放手 提交于 2019-12-09 19:42:09
问题 In our database, we have the following tables Tags Id (int) Name (string) IsActive (bool) TagType (string) and DocumentStyles Id (int) Name (string) StyleRules (string) IsAvailable (bool) ThumbnailFileId (int nullable) ConceptTagId (int nullable) With the EF 4.2 designer, I've created the appropriate entities, and am trying to link the foreign key of ConceptTagId to the Tag model. When I add the association (0..1 to many from Tag to DocumentStyle), it correctly links the foreign key and adds

The entity type <class> is not part of the model for the current context

﹥>﹥吖頭↗ 提交于 2019-12-05 20:59:25
问题 This is a MODEL first approach. I have already researched this extensiely and have not come up with an answer. I have tried all the suggestions at the following links: This appears to be the same problem but with no resolution The entity type <classname> is not part of the model for the current context These are the links I have already researched so please don't answer as duplicate of ---- EF 4.1 Code First error - The entity type SomeType is not part of the model for the current context The

Code first migrations - what connection string will it use?

自闭症网瘾萝莉.ら 提交于 2019-12-05 11:51:55
问题 Code first migrations have been working very well for me. I have a services project and a wpf project. The model is in the services project which is referenced by the wpf project. Update-database is done on the services project, but uses connection string from the wpf project. I now add a web project which also references the service project. So now that there is a connection string in the app.config and there is one in the web.config, which one will it use? 回答1: In my scenario, the app

Get entity facets and other metadata on runtime

江枫思渺然 提交于 2019-12-04 05:32:03
问题 I have .NET 4.0 WinForms Application, and I use Entity Framework 5 with Model First Approach. In VS EF Designer, I have created a dozen or so entities with a lot of scalar properties of String type, then in Properties Toolbar I have configured parameters (i.e. General parameters, Facets Parameters) for them, to fit DB requirements. In BL layer I am able to validate entity object in purpose to check whether it contains correct values, for example by using DbContext.Entry(Of T)(entity)

How to avoid data loss with EF Model First database schema upgrade?

二次信任 提交于 2019-12-04 04:54:30
This is a long question, but I would be very very thankful if I can get some good advice on this. In short, I’m looking for a good approach for version upgrade of MS SQL database schema that also demands data being moved from deleted tables into new tables. I think Stack Overflow is the most appropriate place for this question (not dba.stackexchange.com) because at its core, this is an issue for .NET developers using Entity Framework, and the database parts of this consists mostly of auto-generated sql scripts. Background A .NET application and SQL database is running in Azure (The application