GithubHelp home page GithubHelp logo

czemacleod / c3d.msbuild.tools.ef6.generateviews Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 61 KB

Codebase for an MSBuild based version of the Entity Framework 6 Power Tools Generate Views command

License: MIT License

PowerShell 2.26% C# 97.74%
msbuild-task ef6 ef6-migrations edmx code-generation

c3d.msbuild.tools.ef6.generateviews's People

Contributors

czemacleod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

gregpsn

c3d.msbuild.tools.ef6.generateviews's Issues

Is there a way to use the generated views in a super class of the Context?

We have a DB first context like AcmeContext : DbContext, which is automatically created. We then have a superclass of this with our customisations SuperAcmeContext : AcmeContext. However, the superclass cannot access the generated views because they are sealed.

I think if the views were not sealed OR the DbMappingViewCacheTypeAttribute allowed for a parameterised type then it would work. For example [assembly: DbMappingViewCacheTypeAttribute(SuperAcmeContext,...)

Any ideas if there is a workaround?

Duplicate EDMX Items in Solution Explorer

Thank you so much for providing this. Not only does it help with not needing the Power Tools anymore, but it also means I don't have to worry about remembering to generate mapping views. Can't tell you how many times I spaced that step and broke the build...

Anyway, now that I have the two entries in my csproj file (EntityView and EntityDeploy), the edmx is duplicated in the Solution Explorer. Am I doing something wrong, is there a way around that, or is that just a side effect we'll have to live with?

<EntityDeploy Include="iMISEntities.edmx">
  <Generator>EntityModelCodeGenerator</Generator>
  <LastGenOutput>iMISEntities.Designer.cs</LastGenOutput>
</EntityDeploy>
<EntityView Include="iMISEntities.edmx">
  <Generator>
  </Generator>
  <CustomToolNamespace>Model</CustomToolNamespace>
</EntityView>

image

Thanks again!

~Justin

How to know if it worked?

I am using code first migrations. In VS2019, I used EF Power Tools to give me an Entity Framework menu on my DBContext class file in the solution explorer.
When I selected Generate Views, it would take about a minute to generate the views. The result was a DBContext.Views.cs file added to the project.

Since EF Power Tools isn't available for VS2022, I am trying to migrate to your build tool. It sounds great but I am not sure I have it installed properly.

Here is what I did:

  1. I installed the NuGet package into my MVC Project. I have many projects within the solution. The SkyCourt project is the start up project that is where the MVC app lives. This is also where the migrations live. I have another project called SkyCourt.Models that is where the DBContext class lives. This is where the .Views.cs file used to live.
  2. I deleted the .Views.cs file from my project
  3. I unloaded the SkyCourt project and edited the file to add the code snippet from the main page of your project.
  4. I loaded the project and made a change to the model.
  5. I then opened the package manager and ran Add-Migration
  6. I then ran Update-Database

Everything went well, but I am not sure that that the Views were created. I have no .edmx in my solution view. And when I did the Udpate-Database, it took about 2 seconds where normally view generation takes about 60 seconds.

I looked in the obj directory for SkyCourt and I do not see anything called EntityViews.

Did I miss something?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.