sql server - Defining View in Entity Data Model -


i trying add view entity data model error below. view group count. don’t understand because view not have primary key it’s nature.

i modified original post because figured out how add key view. still have same problem.

warning 6013: table/view 'fmcsa.dbo.viefmcsadocumentcount' not have primary key defined , no valid primary key inferred. table/view has been excluded. use entity, need review schema, add correct keys, , uncomment it.

here view

create view [dbo].[viefmcsadocumentcount] schemabinding

as select     count_big(*) countofdocs, role_id, owner_id         dbo.fmcsa_document group role_id, owner_id 

then can add key

create unique clustered index [mainindex] on [dbo].[viefmcsadocumentcount]  (     [owner_id] asc,     [role_id] asc ) 

still not working.

you didn't specify, i'm assuming you're using ef4. i've come across before--you either want define key manually or edit recreate view with schemabinding , reimport.

schema binding tells sql track dependencies view. it's both blessing , curse (try adding column fmcsa_document once view has schema binding), might want read on effects.

create view [dbo].[viefmcsadocumentcount] schemabinding    select count(id) countofdocs, role_id, owner_id     dbo.fmcsa_document group role_id, owner_id 

alternately, in ef model browser go entity types folder, find view (right click , choose show in designer). on view, highlight column(s) comprise primary key , right click , choose "entity key"


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -