简体   繁体   中英

Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs

I will be using Solr search server with my ASP.NET 4.5 application. I've already installed SOLR on my Windows 8 laptop computer. According to SolrNet this documentation , I need to use specific attributes on my POCOs.

The thing is that I am using Entity Framework and my classes are auto generated. Is there an option to assign those type of Solr attributed and also make sure that they are presistant and won't be erased if your suggested solution is based on editing the template (.tt) file.

I want to use Entity Framework, but if it is not possible, I will just copy the pocos and create the classes myself with those Attributes. But I prefer searching for a solution that will allow me to use solrnet with Entity Framework. Thanks.

I would suggest that you create separate classes that map to your Solr Index schema, as typically the structure of your EF classes and your index schema will not be identical. This way you have a clean separation between your persistence classes (those auto-generated by EF) and your index mapping classes and can control how the mapping between the two occurs. I recommend the use of AutoMapper to assist with translating your objects from EF to Solr and back again as needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM