Entity Framework 4.0 generating read only model when I create model from existing database

c# entity-framework sql

Question

I am integrating Entity Framework support in Visual Studio 2010 using a bespoke ado.net provider that I am developing. For table objects, I'm building every conceivable mapping and reading all pertinent database metadata. A table with main keys and additional fields is used in my test. I get a model with all the column mappings and everything when I construct a model from a database using this table, but I also get the following error messages:

The model was generated with warnings or errors. Please see the Error List for more details. These issues must be fixed before running your application. Loading metadata from the database took 00:00:11.4799371. Generating the model took 00:00:04.2751189. Added the connection string to the App.Config file. Writing the .edmx file took 00:00:00.0005060.

The following error appears when I use an XML editor to open the.edmx file:

<!--Errors Found During Generation:
  warning 6002: The table/view 'sqlfire.APP.CUSTOMERS' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
  -->

A DefiningQuery containing a SELECT... command for the table was also included.

I'm trying to solve this problem in circles and am in dire need of assistance.

1
6
2/20/2014 11:12:44 PM

Popular Answer

It appears from the error notice that one of your tables or views lacks a Primary-Key.EF requires a Primary-Key in each table to produce entity keys.

You might still be able to execute your application, but I really advise that you do as I said and add primary keys.

12
11/8/2017 12:44:42 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow